/* Examples of Analysis of Random Effects Model */ /* We analyze the Apex Enterprises data from Chapter 25. */ DATA apex; INPUT rating officer candidate; cards; 76 1 1 65 1 2 85 1 3 74 1 4 59 2 1 75 2 2 81 2 3 67 2 4 49 3 1 63 3 2 61 3 3 46 3 4 74 4 1 71 4 2 85 4 3 89 4 4 66 5 1 84 5 2 80 5 3 79 5 4 ; run; PROC GLM data = apex; CLASS officer; MODEL rating = officer; RANDOM officer; run; /* We use the RANDOM statement to tell SAS that "officer" has random levels. */ /* We see there is significant variation in rating among the population */ /* of officers. (F* = 5.39, P-value = 0.0068.) */ /*********************************************************************************/ /* 90% CI for mu-dot and 90% CI for sigma^2 */ PROC MIXED data = apex method = reml ASYCOV CL COVTEST ALPHA = 0.10; /* The ASYCOV CL COVTEST ALPHA = 0.10 part */ /* of the above line gives the 90% CI for sigma^2 */ CLASS officer; MODEL rating = / CL ALPHA = 0.10; /* The above line gives the 90% CI for mu-dot */ /* (for the mean rating of all personnel officers). */ RANDOM officer; run; /* The 90% CI for sigma^2 is (43.98, 151.39). (Find this on the SAS output.) */ /* The 90% CI for mu-dot is (61.98, 80.92). (Find this on the SAS output.) */ /*********************************************************************************/ /* CI for intraclass correlation coefficient and CI for sigma_mu^2 */ DATA ciinfo; ALPHA = 0.10; /*This gives a 90% CI, can be changed depending on needed confidence level*/ n = 4; /* input number of observations per cell */ r = 5; /* input number of levels of the random factor */ MSTR = 394.925; /* input MSTR from PROC GLM output above */ MSE = 73.28333; /* input MSE from PROC GLM output above */ /* lots of calculations */ fl=finv(1-alpha/2,r-1,r*(n-1)); fu=finv(alpha/2,r-1,r*(n-1)); l=1/n*((mstr/mse)*(1/fl)-1); u=1/n*((mstr/mse)*(1/fu)-1); LCL_ICC=l/(1+l); UCL_ICC=u/(1+u); c1=1/n; c2=-1/n; lhat=(mstr-mse)/n; f1=finv(1-alpha/2,r-1,9999); f2=finv(1-alpha/2,r*(n-1),9999); f3=finv(1-alpha/2,9999,r-1); f4=finv(1-alpha/2,9999,r*(n-1)); f5=finv(1-alpha/2,r-1,r*(n-1)); f6=finv(1-alpha/2,r*(n-1),r-1); g1=1-(1/f1); g2= 1-(1/f2); g3=((f5-1)**2-(g1*f5)**2-(f4-1)**2)/f5; g4=f6*(((f6-1)/f6)**2-(((f3-1)/f6)**2)-g2**2); hl=(((g1*c1*mstr)**2)+(((f4-1)*c2*mse)**2)-g3*c1*c2*mstr*mse)**.5; hu=(((f3-1)*c1*mstr)**2+((g2*c2*mse)**2)-(g4*c1*c2*mstr*mse))**.5; LCL_sigma_mu_sq=lhat-hl; UCL_sigma_mu_sq=lhat+hu; run; /* Printing out the Confidence Limits for the CIs */ /* for intraclass correlation coefficient and for sigma_mu^2 */ PROC PRINT data=ciinfo; VAR LCL_ICC UCL_ICC LCL_sigma_mu_sq UCL_sigma_mu_sq; run; /* A 90% CI for the intraclass correlation coefficient is (0.160, 0.884). */ /* Compare to book's result, at top of page 1041. */ /* A 90% CI for sigma_mu^2 is (20.22, 536.32). */ /* Compare to book's result, at bottom of page 1046. */ /*********************************************************************************/ /* Example with Mixed Effect Model */ /* Training Data Example */ /* These are NOT the same data as in the training example in the book! */ DATA training; INPUT method instructor improvement; cards; 1 1 54.93 1 2 46.29 1 3 47.14 1 4 39.72 1 5 49.32 1 1 40.33 1 2 56.33 1 3 48.54 1 4 60.89 1 5 50.25 1 1 54.08 1 2 48.51 1 3 52.40 1 4 54.98 1 5 48.96 1 1 45.39 1 2 52.42 1 3 56.59 1 4 44.13 1 5 46.37 2 1 19.07 2 2 30.74 2 3 30.35 2 4 29.85 2 5 30.92 2 1 32.22 2 2 24.23 2 3 32.54 2 4 23.99 2 5 25.04 2 1 27.12 2 2 14.19 2 3 28.28 2 4 24.67 2 5 27.54 2 1 29.18 2 2 35.32 2 3 23.51 2 4 29.06 2 5 25.14 3 1 32.92 3 2 20.99 3 3 28.65 3 4 32.25 3 5 21.21 3 1 29.83 3 2 36.29 3 3 31.35 3 4 26.93 3 5 34.68 3 1 35.59 3 2 27.31 3 3 21.22 3 4 28.29 3 5 36.33 3 1 18.53 3 2 23.54 3 3 31.12 3 4 33.22 3 5 30.59 4 1 27.18 4 2 22.07 4 3 36.81 4 4 28.11 4 5 26.4 4 1 36.45 4 2 29.66 4 3 26.21 4 4 38.15 4 5 43.22 4 1 44.9 4 2 33.57 4 3 25.49 4 4 23.67 4 5 32.52 4 1 29.13 4 2 26.42 4 3 22.8 4 4 45.81 4 5 31.36 ; PROC GLM data=training; CLASS method instructor; MODEL improvement = method instructor method*instructor; RANDOM instructor; TEST h=method e=method*instructor; MEANS method / TUKEY CLDIFF ALPHA=0.05; run; /* We use the RANDOM statement to tell SAS that "instructor" has random levels. */ /* For the test about the fixed-effect factor (method), we must tell SAS, using */ /* a TEST statement, that the correct denominator is MSAB (method*instructor). */ /* Note the correct results of this test (F*=135.7, P-value < .0001) are given */ /* on a separate page of output. */ /* Since there was a significant effect due to method, we can use Tukey's procedure */ /* to determine which methods specifically differ. At family significance level 0.05, */ /* method 1 differs from each of methods 2, 3, and 4. But no pair among methods 2, 3,*/ /* and 4 are significantly different. */ /*********************************************************************************/