qqline does not give the line that I expected

multivariate-testing, plot, quantile, r

Solution

By default `qqline` draws a line through the first and third quartiles. See the help file (`?qqline`).

#highlight first and third quartiles
points(quantile(chi_scores,c(.25,.75)),
       quantile(mah_scores,c(.25,.75)),col="blue",cex=2,bg="blue",pch=21)

Problem

If I perform a multivariate qqplot of the mahalanobis distance of my multivariate data plotted against the Chi-squared distribution, I expect the accompanying qqline to be a line with intercept 0 and slope 1. But if I run the following code: ``` scores<-matrix(rnorm(100*3),nc=3) mah_scores = mahalanobis(scores,center=colMeans(scores),cov=cov(scores)) chi_scores = qchisq(ppoints(nrow(scores)),df=3) qqplot(x=chi_scores,y=mah_scores,asp=1) abline(a=0,b=1) qqline(mah_scores, distribution = function(p) qchisq(p,df = 3),col="red") ``` I get the following figure: I expected the qqline (in red) to be the same as the line with intercept 0 and slope 1 (in black). Can anyone explain to me why these 2 lines don't match up? (I'm running R version 2.15.3 (2013-03-01))

Original source