
The Chi-Square Plot plots the ordered robust mahalanobis distances of the data against the quantiles of the Chi-squared distribution. If the data is normal distributed these values should approximately correspond to each other, so outliers can be detected visually. By user interaction this procedure is repeated, each time leaving out the observation with the greatest distance (the number of the observation is printed on the console). This method can be seen as an iterativ deletion of outliers until a straight line appears. I write this syntax to plot it. If you have any problem, please let me know.
SET MXLOOP =99999.
MATRIX.
GET DATA/VARIABLES=X1 to X4/MISSING=OMIT.
COMPUTE NR=NROW(DATA).
COMPUTE NC=NCOL(DATA).
COMPUTE MEAN=T(CSUM(DATA)/NR).
PRINT MEAN.
COMPUTE SIGMA=(SSCP(DATA)-NR*MEAN*T(MEAN))/(NR-1).
PRINT SIGMA.
COMPUTE MD=MAKE(NR,2,-999).
COMPUTE MDTEMP=MAKE(NR,1,-999).
LOOP I=1 TO NR.
- COMPUTE MD(I,1)=DATA(I,:)*INV(SIGMA)*T(DATA(I,:)).
END LOOP.
COMPUTE MD(:,2)=(RNKORDER(MD(:,1))-0.5)/NR.
SAVE MD /OUTFILE=*.
END MATRIX.
RENAME VARIABLES COL1= MD COL2= CHISQUARE.
GRAPH
/SCATTERPLOT(BIVAR)=MD WITH CHISQUARE /MISSING=LISTWISE
/TITLE= 'The chi-square plot of the ordered distances.'.
2008年3月23日 星期日
Chi-Square Plot by SPSS
訂閱:
張貼留言 (Atom)
沒有留言:
張貼留言