*-----------------------------------------------------------------------------; * Illustrations of different approaches to repeated measures analysis ; *-----------------------------------------------------------------------------; /* Overview of approaches: 1) a multivariate analysis (MANOVA) 2) use split-plot analysis with potentially downweighted split plot degrees of freedom 3) define contrasts among time levels, reducing complexity 4) model the covariance structure 5) use random coefficient models */ * data from microbial CO2 growth over time under different moisture conditions from "Design of Experiments: Statistical Principles of Research Design and Analysis" by Robert O. Kuehl, second edition, page 504. ; data table156multi ; input moisture $ container CO2day2 CO2day4 CO2day6 CO2day8 ; linearCO2 = -3*CO2day2 -1*CO2day4 +1*CO2day6 +3*CO2day8 ; quadraticCO2 = 1*CO2day2 -1*CO2day4 -1*CO2day6 +1*CO2day8 ; cubicCO2 = -1*CO2day2 +3*CO2day4 -3*CO2day6 +1*CO2day8 ; cards ; Control 1 .22 .56 .66 .89 Control 2 .68 .91 1.06 .80 Control 3 .68 .45 .72 .89 P24 4 2.53 2.7 2.1 1.5 P24 5 2.59 1.43 1.35 0.74 P24 6 0.56 1.37 1.87 1.21 P26 7 0.22 0.22 0.20 0.11 P26 8 0.45 0.28 1.24 0.86 P26 9 0.22 0.33 0.34 0.20 P28 10 0.22 0.80 0.80 0.37 P28 11 0.22 0.62 0.89 0.95 P28 12 0.22 0.56 0.69 0.63 ; proc print data = table156multi ; run ; *-----------------------------------------------------------------------------; * Second approach to repeated measures ; * The first approach is also included if the 'nom' option is removed ; *-----------------------------------------------------------------------------; * this repeated measures analysis conducts the second approach mentioned in the text, where the F test degrees of freedom are downweighted due to violation of the Huynh-Feldt condition ; proc glm data = table156multi ; class moisture container ; model CO2day2 CO2day4 CO2day6 CO2day8 = moisture / nouni ; repeated days / nom printe ; run ; *-----------------------------------------------------------------------------; * Third approach to repeated measures ; *-----------------------------------------------------------------------------; * this analysis is the third approach in the text, where contrasts among the repeated measure are defined and univariate ANOVA is used ; proc glm data = table156multi ; class moisture container ; model CO2day2 CO2day4 CO2day6 CO2day8 = moisture / nouni ; repeated time polynomial / nom printe summary ; run ; *-----------------------------------------------------------------------------; * Fourth approach to repeated measures ; *-----------------------------------------------------------------------------; * Note that the data structure is different for repeated measures analysis in Proc MIXED vs Proc GLM. GLM requires a multivariate format, while MIXED uses a univariate format ; data table156uni ; input moisture $ container day CO2 @@ ; cards ; Control 1 2 .22 Control 1 4 .56 Control 1 6 .66 Control 1 8 .89 Control 2 2 .68 Control 2 4 .91 Control 2 6 1.06 Control 2 8 .80 Control 3 2 .68 Control 3 4 .45 Control 3 6 .72 Control 3 8 .89 P24 4 2 2.53 P24 4 4 2.7 P24 4 6 2.1 P24 4 8 1.5 P24 5 2 2.59 P24 5 4 1.43 P24 5 6 1.35 P24 5 8 0.74 P24 6 2 0.56 P24 6 4 1.37 P24 6 6 1.87 P24 6 8 1.21 P26 7 2 0.22 P26 7 4 0.22 P26 7 6 0.20 P26 7 8 0.11 P26 8 2 0.45 P26 8 4 0.28 P26 8 6 1.24 P26 8 8 0.86 P26 9 2 0.22 P26 9 4 0.33 P26 9 6 0.34 P26 9 8 0.20 P28 10 2 0.22 P28 10 4 0.80 P28 10 6 0.80 P28 10 8 0.37 P28 11 2 0.22 P28 11 4 0.62 P28 11 6 0.89 P28 11 8 0.95 P28 12 2 0.22 P28 12 4 0.56 P28 12 6 0.69 P28 12 8 0.63 ; proc print data = table156uni ; run ; * This approach is related to the multivariate approach mentioned in the text, in that it models the multivariate structure among the repeated measures ; * The general approach to repeated measures analysis in Proc MIXED is to find the best fitting covariance model, then to base tests on fixed effects from this model. Different covariance models are specified via the 'type = ' option in the REPEATED statement, and a criterion such as the model AIC or BIC can be used to select the best covariance structure ; proc mixed data= table156uni ; class moisture container day ; model CO2 = moisture day moisture*day ; repeated / type=cs sub= container(moisture) r rcorr; run ; proc mixed data= table156uni ; class moisture container day ; model CO2 = moisture day moisture*day / ddfm = kr ; repeated / type= ar(1) sub= container(moisture) r rcorr; run ; proc mixed data= table156uni ; class moisture container day ; model CO2 = moisture day moisture*day / ddfm = kr outp = rtable156uni1 ; repeated day / type= arh(1) sub= container(moisture) r rcorr; lsmeans moisture*day ; ods output lsmeans = CO2lsm1 ; run ; proc print data = CO2lsm1 ; run ; * a profile plot from the covariance modeling approach using the best fitting model ; proc sgplot data = CO2lsm1 ; series x = day y = estimate / markers group = moisture ; yaxis label = "CO2" values = (0 to 2 by .5) ; xaxis label = "Days" ; TITLE "Profile plot from the covariance pattern approach" ; run ; proc mixed data= table156uni ; class moisture container day ; model CO2 = moisture day moisture*day / ddfm = kr ; repeated / type= un sub= container(moisture) r rcorr; run ; proc plot vpercent = 80 data = rtable156uni1 ; plot resid*pred pred*day=moisture pred*moisture=day ; run ; proc capability noprint lineprinter data = rtable156uni1 ; var resid ; qqplot resid / normal (mu = est sigma = est symbol = '.') square ; run ; *-----------------------------------------------------------------------------; * Fifth approach to repeated measures ; *-----------------------------------------------------------------------------; * Viewing individual plots per container ; proc sgpanel data = table156uni ; panelby moisture container / columns = 3 rows = 4 ; series x = day y = CO2 / markers ; title "Individual plots per container" ; run ; proc mixed data = table156uni ; class moisture container ; model CO2 = moisture day moisture*day / ddfm =kr outp = rtable156uni2 ; * day*day moisture*day*day ; random int day / subject = container(moisture) type = un ; * day*day ; lsmeans moisture / at day = 2 diff ; lsmeans moisture / at day = 4 diff ; lsmeans moisture / at day = 6 diff ; lsmeans moisture / at day = 8 diff ; ods output lsmeans = CO2lsm2 diffs = CO2diffs2 ; run ; proc plot vpercent = 80 data = rtable156uni2 ; plot resid*pred ; run ; proc capability noprint lineprinter data = rtable156uni2 ; var resid ; qqplot resid / normal (mu = est sigma = est symbol = '.') square ; run ; proc sgplot data = CO2lsm2 ; series x = day y = estimate / markers group = moisture ; yaxis label = "CO2" values = (0 to 3 by .5) ; xaxis label = "Days" ; TITLE "Profile plot of the fitted curves from the random coefficient models" ; run ;