qqline没有给出我预期的线

问题描述:

如果我执行我的多元数据的mahalanobis距离与卡方分布相关的多元qqplot,我预计伴随的qqline是一个截距为0和斜率为1的直线。但是,如果我运行下面的代码:qqline没有给出我预期的线

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") 

我得到如下图所示:

qqplot with abline and qqline

我预计qqline(红色)是一样的截距0和斜率线1(黑色)。任何人都可以向我解释为什么这两行不匹配?

(我运行v版本2.15.3(2013-03-01))

默认情况下qqline绘制一条线穿过第一和第三个四分位数。请参阅帮助文件(?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) 

enter image description here