2013-03-16 3 views
1

카이 제곱 분포에 대해 플롯 한 다변량 데이터의 mahalanobis 거리의 다 변수 qqplot을 수행하면 동반되는 qqline이 절편 0과 기울기 1이있는 라인이 될 것으로 기대합니다. 그러나 나는 다음과 같은 코드를 실행하는 경우 : 나는 (빨간색)을 qqline 예상 qqplot with abline and qqlineqqline이 예상 한 라인을 제공하지 않습니다.

은 절편 0과 경사가있는 라인과 동일하기 : 나는 다음과 같은 그림을 얻을

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

을 1 (검은 색). 아무도 왜이 두 라인이 일치하지 않는지 설명 할 수 있습니까?

(I은 R 버전 2.15.3 (2013년 3월 1일)를 실행하고있어) 기본 qqline으로

답변

3

은 첫 번째와 세 번째 분위수를 통해 선을 그립니다. 도움말 파일 (?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

관련 문제