# What is the use of the line produced by qqline() in R?

The `qqnorm()` R function produces a normal QQ-plot and `qqline()` adds a line which passes through the first and third quartiles. What is the origin of this line? Is it helpful to check normality? This is not the classical line (the diagonal $y=x$ possibly after linear scaling).

Here is an example. First I compare the empirical distribution function with the theoretical distribution function of ${\cal N}(\hat\mu,\hat\sigma^2)$: Now I plot the qq-plot with the line $y=\hat\mu + \hat\sigma x$; this graph roughly corresponds to a (non-linear) scaling of the previous graph: But here is the qq-plot with the R qqline: This last graph does not show the departure as in the first graph.

-

## 1 Answer

As you can see on the picture,

obtained by

````> y <- rnorm(2000)*4-4
> qqnorm(y); qqline(y, col = 2,lwd=2,lty=2)
````

the diagonal would not make sense because the first axis is scaled in terms of the theoretical quantiles of a $\mathcal{N}(0,1)$ distribution. I think using the first and third quartiles to set the line gives a robust approach for estimating the parameters of the normal distribution, when compared with using the empirical mean and variance, say. Departures from the line (except in the tails) are indicative of a lack of normality.

-
The diagonal "after linear scaling" is here obtained by abline(mean(y), sd(y)). Here you simulate normal data hence these two lines are close. But sometimes the data is not close to a normal distribution but the qqplot is close to the qqline, but not to the diagonal "after scaling". – Stéphane Laurent Feb 4 '12 at 11:45
... I'm going to add an example to my question – Stéphane Laurent Feb 4 '12 at 11:53

1
I think this was my point in stating that using the quartiles is more robust than using empirical mean and variance. – Xi'an Feb 4 '12 at 14:56

1
Ok, thank you very much. Now this seems obvious. The qqline could be preferable because sometimes in practice the non-normality in the tails is acceptable. But there is no real need to plot the qqline: a visual check is sufficient - the only thing we need is to understand the QQ-plot :) – Stéphane Laurent Feb 4 '12 at 16:25

1
Ok - I tag, but the answer itself was not satisfactory: the answer together with our discussion is ; but this is my fault: my question was not clear before I add the example. By the way my question is somewhat related to the KS-test: what about the choice of the estimates $\hat\mu$ and $\hat\sigma$ when we type ks.test(x,"pnorm",mu.hat,sigma.hat) ? – Stéphane Laurent Feb 4 '12 at 19:04
show 8 more comments
default
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 6, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9169198274612427, "perplexity_flag": "middle"}