1 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
55
56 /************* classicalmixed.sas *********************
57 Three levels of factor A, four levels of B
58 Both fixed
59 Both random
60 A fixed, B random
61 B nested within A
62 ***************************************************/
63
64 data mixedup;
65 infile '/folders/myfolders/mixedup.data.txt';
66 input ID Y A B;
67
NOTE: The infile '/folders/myfolders/mixedup.data.txt' is:
Filename=/folders/myfolders/mixedup.data.txt,
Owner Name=root,Group Name=vboxsf,
Access Permission=-rwxrwx---,
Last Modified=05Mar2016:15:49:20,
File Size (bytes)=972
NOTE: 36 records were read from the infile '/folders/myfolders/mixedup.data.txt'.
The minimum record length was 25.
The maximum record length was 25.
NOTE: The data set WORK.MIXEDUP has 36 observations and 4 variables.
NOTE: DATA statement used (Total process time):
real time 0.00 seconds
cpu time 0.01 seconds
68 proc glm plots=none;
69 title 'Default proc glm: Both Fixed';
70 class A B ;
71 model y = a | b;
72 means a*b;
73
NOTE: Means from the MEANS statement are not adjusted for other terms in the model. For adjusted means, use the LSMEANS statement.
NOTE: PROCEDURE GLM used (Total process time):
real time 0.10 seconds
cpu time 0.10 seconds
74 proc glm plots=none;
75 title 'Both Random with proc glm';
76 class A B ;
77 model y = a | b;
78 random a b a*b / test ;
79 /* Have to specify interaction random too,
80 and explicitly ask for tests */
81
NOTE: TYPE I EMS not available without the E1 option.
NOTE: PROCEDURE GLM used (Total process time):
real time 0.09 seconds
cpu time 0.09 seconds
82 proc glm plots=none;
83 title 'A Fixed, B Random';
84 class A B ;
85 model y = a | b;
86 random b a*b / test;
87
NOTE: TYPE I EMS not available without the E1 option.
NOTE: PROCEDURE GLM used (Total process time):
real time 0.09 seconds
cpu time 0.08 seconds
88 proc glm plots=none;
89 title 'A fixed, B random and nested within A';
90 class A B ;
91 model y = a b(a);
92 random b(a) / test;
93
NOTE: TYPE I EMS not available without the E1 option.
NOTE: PROCEDURE GLM used (Total process time):
real time 0.09 seconds
cpu time 0.09 seconds
94 proc mixed cl; /*Confidence Limits for variances (There are no tests) */
95 title 'A fixed, B random and nested within A';
96 title2 'Using proc mixed';
97 title3 'Compare F for A = 7.32, F for B(A) = 3.11, p = 0.0126';
98 class A B ;
99 model y = a ;
100 random b(a);
101
NOTE: Convergence criteria met.
NOTE: PROCEDURE MIXED used (Total process time):
real time 0.08 seconds
cpu time 0.07 seconds
102 proc glm plots=none;
103 title 'Both random, B nested within A';
104 class A B ;
105 model y = a b(a);
106 random a b(a) / test;
107
NOTE: TYPE I EMS not available without the E1 option.
NOTE: PROCEDURE GLM used (Total process time):
real time 0.09 seconds
cpu time 0.08 seconds
108 proc sort; by A B; /* Data must be sorted in order of nesting*/
NOTE: There were 36 observations read from the data set WORK.MIXEDUP.
NOTE: The data set WORK.MIXEDUP has 36 observations and 4 variables.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
109 proc nested;
110 title 'Nested random effects with proc nested';
111 title2 'Compare F for A = 7.32, F for B(A) = 3.11';
112 class A B;
113 var Y;
114
NOTE: PROCEDURE NESTED used (Total process time):
real time 0.04 seconds
cpu time 0.04 seconds
115 proc mixed cl;
116 title 'Pure nested with proc mixed';
117 class A B ;
118 model y = ;
119 random a b(a);
120
121 /****** What happens when the data are unbalanced? ******/
122
NOTE: Convergence criteria met.
NOTE: PROCEDURE MIXED used (Total process time):
real time 0.06 seconds
cpu time 0.06 seconds
123 proc glm plots=none;
124 title 'UNBALANCED: Both random, B nested within A';
125 title2 'Using proc glm';
126 title3 'Compare F for A = 7.32, F for B(A) = 3.11';
127 where id ne 1; /* Throw out one case */
128 class A B ;
129 model y = a b(a);
130 random a b(a) / test;
131
NOTE: TYPE I EMS not available without the E1 option.
NOTE: PROCEDURE GLM used (Total process time):
real time 0.10 seconds
cpu time 0.09 seconds
132 proc sort; by A B; /* Data must be sorted in order of nesting*/
NOTE: Input data set is already sorted, no sorting done.
NOTE: PROCEDURE SORT used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
133 proc nested;
134 title 'UNBALANCED: Nested random effects with proc nested';
135 title2 'Proc glm gave F for A = 7.38, F for B(A) = 2.77';
136 where id ne 1; /* Throw out one case */
137 class A B;
138 var Y;
139
WARNING: The design is not balanced--F tests cannot be computed.
NOTE: PROCEDURE NESTED used (Total process time):
real time 0.04 seconds
cpu time 0.03 seconds
140 proc mixed cl;
141 title 'UNBALANCED: Pure nested with proc mixed';
142 title2 'Proc nested estimated Var[A]=14.39, Var[B(A)]=6.25';
143 where id ne 1; /* Throw out one case */
144 class A B ;
145 model y = ;
146 random a b(a);
147
148
149
150
151
152 OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
164