*** Provided by Instructor Ruey S. Tsay *** University of Chicago *** *** *** Splus commands used to generate chi-square QQ-plot *** for checking multivariate normality assumption. *** *** Data setis denoted by "da". > nr = dim(da)[1] > nc = dim(da)[2] > cm=matrix(colMeans(da),1,nc) <== Obtain the sample means > o=matrix(rep(1,nr),nr,1) > dev=da-kronecker(o,cm) <== Remove sample means from data > s=t(dev)%*%dev <== Sample covariance matrix > si=ginverse(s) > d2=sort(diag(dev%*%si%*%t(dev))) <== Compute and sort the squared distance > prob=(c(1:nr)-0.5)/nr > q1=qchisq(prob,nr) <=== Obtain quantiles of Chi-square dist. > plot(q1,d2) *** May add a straightline to the plot > fit = lsfit(q1,d2) > fitted = d2-fit$residuals > lines(q1,fitted)