/********************************************************* * Chapter 5 Example 5.2 in Johnson and Wichern 5th ed * * Testing Multivariate Mean Vector * **********************************************************/ DM "output;clear;log;clear"; Options pagesize=45 linesize=80 PageNo=1 NoDate; OPTIONS FORMCHAR="|----|+|---+=|-/\<>*"; *To make your document display correctly without SAS Monospace font; Title1 "Example 5.2"; ODS HTML body= "ta5_1-body.html" contents="ta5_1-contents.html" frame= "ta5_1-frame.html" page= "ta5_1-page.html" headtext="Inference about a Mean Vector" anchor="ta5_1"; title "Data in Table 5.1"; Data t5_1; individual+1; Input X1-X3; Label X1="Sweat rate" X2="Sodium" X3="Potassium"; DataLines; 3.7 48.5 9.3 5.7 65.1 8.0 3.8 47.2 10.9 3.2 53.2 12.0 3.1 55.5 9.7 4.6 36.1 7.9 2.4 24.8 14.0 7.2 33.1 7.6 6.7 47.4 8.5 5.4 54.1 11.3 3.9 36.9 12.7 4.5 58.8 12.3 3.5 27.8 9.8 4.5 40.2 8.4 1.5 13.5 10.1 8.5 56.4 7.1 4.5 71.6 8.2 6.5 52.8 10.9 4.1 44.1 11.2 5.5 40.9 9.4 ; Proc Print DATA=t5_1; Id Individual; run; title "Array of Descriptive Statistics for Sweat Data"; Proc IML; Use t5_1; Read ALL var{X1 X2 X3} into X; N=NROW(X); P=NCOL(X); close t5_1; One=SHAPE(1,N,1); MeanVec=(One`*X)/N; *Calculate Mean Vector; M=REPEAT(MeanVec,N,1); Sigma=(X-M)`*(X-M)/(N-1); *Calculate Cov Matrix; print MeanVec, Sigma; InvS=inv(Sigma); mu0={4 50 10}; *Ho: mu=[4,50,10] Ha: mu ne [4,50,10]; T2=N*(MeanVec-mu0)*invS*(MeanVec-mu0)`; *Calculate Hotelling T-square value; CriticalF=(((N-1)*P)/(N-P))*FINV(0.9, P, N-P); F=(N-P)/((N-1)*P)*T2; pval=1-ProbF(F,P,(N-P)); print T2 CriticalF pval; run; data new; set t5_1; Y1=X1-4; Y2=X2-50; Y3=X3-10; *above test is now equivalent to testing Y=0; run; proc glm; model Y1 Y2 Y3 = / nouni; manova h=INTERCEPT / printe printh; run; quit; ODS HTML Close;