EDIT: After reading more all weekend, I've learned a lot of stats and still have no idea how to make this analysis happen in R.
The experiments I need to analyze look like this:
- Subjects were assigned to one of several Treatment groups
- Measurements of each subject were taken on multiple days
My dataset contains the following information:
- Subject = blocking factor (random factor)
- Day = within subject or repeated measures factor (fixed factor)
- Treatment = between subject factor (fixed factor)
- Obs = measured (dependent) variable
Also,
Subject is nested within Treatment and crossed with Day (each Subject is assigned to only one Treatment, and measurements are taken on each Subject on each Day)
The design is unbalanced (or non-orthogonal) because I don't have the same number of Subjects in each Treatment group
The assumption of sphericity is violated
I think I need to do a two-factor ANOVA (Treatment, Day) with repeated measures on one factor (Day). I think this is synonymous with a split-plot ANOVA with two factors, or an ANOVA with 3 factors (Treatment, Day, Subject).
I think mixed models come into this somewhere because I have both a random and two fixed factors.
The problem is that I have no idea how all these pieces of information interact.
Questions:
Does mixed models just refer to the type of linear model that gets fed into the
aov()
analysis?According to Repeated Measures, for a repeated-measures analysis with repeated measures on one factor, the data can be analyzed in several different ways, and the covariance structure (the nature of the correlations between measurements of the same subject) is important.
- How can I calculate the Akaike information criterion in order to determine which covariance structure to use?
- Having done so, how can I specify that I need to use "autoregressive of order 1" [AR(1)], or perhaps "compound symmetry" when doing the analysis?
- I'm pretty sure I need to use a Type II SS because of the unbalanced design. Perhaps the
car
package is called for?
I just want to know whether or not the treatment means are significantly different, and if so, on which days. I'm not sure if there's an interaction with time, or how to calculate standard error of the mean and 95% confidence intervals for each time point so I can graph the data. (If the ANOVA results say the treatment effect is significant, can I then run pairwise t-tests as usual? Do I need to do some kind of Bonferroni adjustment, or a Tukey test, or something, because there are several different treatments? Is there a fancy correction I can do to deal with the repeated measures?)
Here's an example of what the data look like:
mydata <- data.frame(
Subject = c(13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 62, 63, 64, 65, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 62, 63, 64, 65, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 62, 63, 64, 65),
Day = c(rep(c("Day1", "Day3", "Day6"), each=28)),
Treatment = c(rep(c("B", "A", "C", "B", "C", "A", "A", "B", "A", "C", "B", "C", "A", "A", "B", "A", "C", "B", "C", "A", "A"), each = 4)),
Obs = c(6.472687, 7.017110, 6.200715, 6.613928, 6.829968, 7.387583, 7.367293, 8.018853, 7.527408, 6.746739, 7.296910, 6.983360, 6.816621, 6.571689, 5.911261, 6.954988, 7.624122, 7.669865, 7.676225, 7.263593, 7.704737, 7.328716, 7.295610, 5.964180, 6.880814, 6.926342, 6.926342, 7.562293, 6.677607, 7.023526, 6.441864, 7.020875, 7.478931, 7.495336, 7.427709, 7.633020, 7.382091, 7.359731, 7.285889, 7.496863, 6.632403, 6.171196, 6.306012, 7.253833, 7.594852, 6.915225, 7.220147, 7.298227, 7.573612, 7.366550, 7.560513, 7.289078, 7.287802, 7.155336, 7.394452, 7.465383, 6.976048, 7.222966, 6.584153, 7.013223, 7.569905, 7.459185, 7.504068, 7.801867, 7.598728, 7.475841, 7.511873, 7.518384, 6.618589, 5.854754, 6.125749, 6.962720, 7.540600, 7.379861, 7.344189, 7.362815, 7.805802, 7.764172, 7.789844, 7.616437, NA, NA, NA, NA))
Any help figuring out either precisely what sequence of statistical tests I need to run or how to run them in R would be immensely appreciated.
~A Baffled Biologist