qqline没有给出我期望的线

3

如果我对我的多元数据进行马氏距离的多元qq图,并将其绘制在卡方分布上,那么我希望伴随的qq线是一条截距为0,斜率为1的直线。但如果我运行以下代码:

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

我得到了以下图表:

带有abline和qqline的qqplot

我期望的是qqline(红色线)与截距为0且斜率为1的线(黑色线)相同。请问有人能解释一下为什么这两条线不匹配吗?
(我正在运行R版本2.15.3(2013-03-01))
1个回答

5

默认情况下,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


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接