options ls=78;
data one;
input subject l1 l2 l3 l4 r1 r2 r3 r4;
cards;
1 116 119 116 124 120 117 114 122
2 110 110 114 115 106 112 110 110
3 117 118 120 120 120 120 120 124
4 112 116 115 113 115 116 116 119
5 113 114 114 118 114 117 116 112
6 119 115 94 116 100 99 94 97
7 110 110 105 118 105 105 115 115
;
run;
proc transpose data=one out=two(rename=(_name_=eyelens col1=y));
by subject;
run;
data two;
set two;
if (eyelens in ("l1","l2","l3","l4")) then eye="L";
else eye="R";
if (eyelens in ("l1","r1")) then lens=1;
else if (eyelens in ("l2","r2")) then lens=2;
else if (eyelens in ("l3","r3")) then lens=3;
else lens=4;
run;
proc print data=two;
run;
/* The models fit with proc mixed make no adjustments for
non-sphericity. For those models the G-G or H_F adjustment would have to be done by hand. */
title 'Model 1: the RCBD model with random subject (block) effects';
title2 'No adjustment for non-sphericity';
proc mixed data=two method=type3;
class subject lens eye;
model y=lens|eye /ddfm=satterth;
random subject;
lsmeans lens eye lens*eye;
run;
title 'Model 1 refit with PROC GLM';
title2 'Here, adjustments for non-sphericity are done in RM-ANOVA';
* but only for overall treatment effect, without decomposing it into lens effect, eye effect and
interaction. The call to PROC GLM below will give G-G and H-F estimates of epsilon
based on the 8x8 within-subject var-cov matrix.;
proc glm data=one;
model l1 l2 l3 l4 r1 r2 r3 r4= /nouni;
repeated eyelens/printe nom;
* The manova statements below will not be tested with the RM-ANOVA procedure, but rather
as multivariate hypotheses assuming an unstructured within-subject var-cov matrix. So,
these really shouldn't be used in this problem where you were asked to implement RM-ANOVA,
not he unstructure multivariate approach to the analysis.
However, I misled some students in office hours who asked about this. I told them to do these
contrasts this way (using the C matrix in the multivariate linear hypothesis ABC=D,
not realizing that the problem asked for RM-ANOVA, not the unstructured
approach. Therefore, it you did the hypothesis tests this way, I will accept your answer
without marking it wrong.;
manova h=intercept m=(1 1 1 1 -1 -1 -1 -1);
manova h=intercept m=(3 -1 -1 -1 3 -1 -1 -1,
0 2 -1 -1 0 2 -1 -1,
0 0 1 -1 0 0 1 -1);
manova h=intercept m=(3 -1 -1 -1 -3 1 1 1,
0 2 -1 -1 0 -2 1 1,
0 0 1 -1 0 0 -1 1);
run;
title 'Model 2: the RCBD model with random subj, subj*lens and subj*eye effects';
title2 'No adjustment for non-sphericity';
proc mixed data=two method=type3;
class subject lens eye;
model y=lens|eye /ddfm=satterth;
random subject subject*lens subject*eye;
lsmeans lens eye lens*eye;
run;
/* The second model above can be fit with PROC GLM, which will make adjustments
for non-sphericity */
title 'Model 2 refit with PROC GLM';
title2 'Here, adjustments for non-sphericity are done in RM-ANOVA';
proc glm data=one;
model l1 l2 l3 l4 r1 r2 r3 r4= /nouni;
repeated eye 2, lens 4/printe nom;
run;