* data from O'Brien and Kaiser, Psych Bull, 1985; data repmes; input group $ sex $ subj pre1-pre5 post1-post5 fol1-fol5; pre = mean(of pre1-pre5); post = mean(of post1-post5); fol = mean(of fol1-fol5); datalines; Control M 1 1 2 4 2 1 3 2 5 3 2 2 3 2 4 4 Control M 2 4 4 5 3 4 2 2 3 5 3 4 5 6 4 1 Control M 3 5 6 5 7 7 4 5 7 5 4 7 6 9 7 6 Control F 4 5 4 7 5 4 2 2 3 5 3 4 4 5 3 4 Control F 5 3 4 6 4 3 6 7 8 6 3 4 3 6 4 3 Treat_A M 6 7 8 7 9 9 9 9 10 8 9 9 10 11 9 6 Treat_A M 7 5 5 6 4 5 7 7 8 10 8 8 9 11 9 8 Treat_A F 8 2 3 5 3 2 2 4 8 6 5 6 6 7 5 6 Treat_A F 9 3 3 4 6 4 4 5 6 4 1 5 4 7 5 4 Treat_B M 10 4 4 5 3 4 6 7 6 8 8 8 8 9 7 8 Treat_B M 11 3 3 4 2 3 5 4 7 5 4 5 6 8 6 5 Treat_B M 12 6 7 8 6 3 9 10 11 9 6 8 7 10 8 7 Treat_B F 13 5 5 6 8 6 4 6 6 8 6 7 7 8 10 8 Treat_B F 14 2 2 3 1 2 5 6 7 5 2 6 7 8 6 3 Treat_B F 15 2 2 3 4 4 6 6 7 9 7 7 7 8 6 7 Treat_B F 16 4 5 7 5 4 7 7 8 6 7 7 8 10 8 7 ; proc print; var group sex subj pre post fol; proc means mean std; class group; var pre post fol; run; title 'Univariate mixed model approach'; /*--------------------------------------------------* | + Greater power / fewer subjects required | | - Must specify error term for each effect | | - Overly liberal when sphericity not satisfied | | - Data must be reshaped | *--------------------------------------------------*/ data mixed; set repmes; drop pre1-pre5 post1-post5 fol1-fol5; phase ='1:Pre ' ; response=pre; output; phase ='2:Post ' ; response=post; output; phase ='3:FollowUp' ; response=fol; output; proc print; var group sex subj phase response; title2 'Reshaped data for mixed model analysis'; proc glm data=mixed; class group phase subj; model response = group subj(group) phase group*phase / ss3; *-- In this model, the error term for GROUP is SUBJ(GROUP). *-- Contrasts of GROUP use the same error term. test h=group e=subj(group); contrast 'Treat A vs B' group 0 1 -1 / e=subj(group); contrast 'Trt vs Control' group -2 1 1 / e=subj(group); title2; run; title 'Multivariate Approach to Repeated Measures'; /*-------------------------------------------------* | + No assumption of sphericity required | | + Easier: GLM determines error terms | | - Less power WHEN SPHERICITY assumption is met | *-------------------------------------------------*/ proc glm data=repmes; class group; model pre post fol = group / nouni; contrast 'Trt vs Control' group -2 1 1 ; contrast 'Treat A vs B' group 0 1 -1 ; *-- Group x Time effect; manova h=group M = ( -1 1 0, 0 -1 1 ) / short; * manova h=group M = post-pre, fol-post / short; /* same test */ *-- Time effect; manova h=intercept M = ( -1 1 0, 0 -1 1 ) / short; * manova h=intercept M = post-pre, fol-post / short; /* same test */ *-- Group effect; manova h=group M = ( 1 1 1 ) / short; * manova h=group M = pre+post+fol / short; /* same test */ run; title 'Multivariate Approach with REPEATED statement'; /*----------------------------------------------------* | o The REPEATED statement gives both univariate | | (mixed model) and multivariate tests. | | o Produces tests of spehericity and G-G and H-F | | corrected p-values. | *----------------------------------------------------*/ proc glm data=repmes; class group; model pre post fol = group / ss3 nouni; contrast 'Trt vs Control' group -2 1 1 ; contrast 'Treat A vs B' group 0 1 -1 ; REPEATED phase 3 contrast(1) / short summary printM printH printE; run;