[R] Analyzing an unbalanced AB/BA cross-over design

Russell Reeve rreeve at liposcience.com
Wed Jan 29 16:50:41 CET 2003


For Type III SS, the sequence effect is determined by the subject, since subject is nested within sequence Type III gives the additional reduction in the residual SS after accounting for the other model terms. For Type I SS, you get the reduction in the residual SS after accounting for the model terms before the term in question. Since subject within sequence comes after subject, you get subject Type I SS. Note that you can omit the sequence effect entirely 

lm(outcome~treatment+period+subject, data=example)

The contrast of interest (on treatment) will not be affected. One should also note that sequence is confounded with period by treatment interaction, so beware. Further, the subject that has an observation missing is essentially removed from the analysis (doesn't affect the results). But that is not true if you use a mixed effect modeling engine, i.e.,

library(nlme)
my.lme <- lme(outcome~treatment+period, data=example, random=~1|subject)

In this model, all 8+7 observations affect the likelihood, and are used in fitting the fixed effects: The mixed effect model and the purely fixed effect model will give difference results for unbalanced data, same results for balanced data.

summary(my.lme) give the output:

Linear mixed-effects model fit by REML
 Data: example 
       AIC      BIC    logLik
  265.1293 270.8068 -127.5647

Random effects:
 Formula: ~1 | subject
        (Intercept) Residual
StdDev:    66.52344 27.39351

Fixed effects: outcome ~ treatment + period 
               Value Std.Error DF   t-value p-value
(Intercept) 333.8187  20.56392 12 16.233219  <.0001
treatmentS  -46.6071  10.77655 11 -4.324868  0.0012
period2      15.8929  10.77655 11  1.474763  0.1683
 Correlation: 
           (Intr) trtmnS
treatmentS -0.242       
period2    -0.242 -0.077

Standardized Within-Group Residuals:
        Min          Q1         Med          Q3         Max 
-1.69842428 -0.41583473  0.06268074  0.52314988  1.28230120 

Number of Observations: 26
Number of Groups: 13 

The difference in means of treatment levels is S - F = -46.6, with SE 10.78.

If you add the sequence term to test for period by treatment interaction, you get fixed effects

Fixed effects: outcome ~ treatment + period + sequence 
               Value Std.Error DF   t-value p-value
(Intercept) 337.1429  28.27660 11 11.923035  <.0001
treatmentS  -46.6071  10.77654 11 -4.324871  0.0012
period2      15.8929  10.77654 11  1.474765  0.1683
sequence2    -7.2024  40.20272 11 -0.179152  0.8611

The sequence effect is not statistically significant (P=0.8611), and so one would not worry about treatment by period interaction here. If one had observed significant sequence effect, then one would need to either (a) analyze only the first period data, or (b) explain why the interaction is not real and can be ignored.

The advantages to the lme() analysis over the lm() analysis are: (1) sequence effect automatically gets appropriate denominator (not so for the lm version) (2) all data are actually used in the analysis, (3) We are trying to infer to the population of subjects, hence they should be thought of as random effects, not fixed effects (unless you really are interested in only those particular subjects).

If any of this is confusing, let me know.

Russell Reeve, Ph.D.
Dir of Experimental Design, Analysis, and Quality
rreeve at liposcience.com




More information about the R-help mailing list