I am trying to analyse some data using a mixed effect model. The data I collected represent the weight of some young animals of different genotype over time.
I am using the approach proposed here:
https://gribblelab.wordpress.com/2009/03/09/repeated-measures-anova-using-r/
In particular I'm using solution #2
So I have something like
require(nlme)
model <- lme(weight ~ time * Genotype, random = ~1|Animal/time,
data=weights)
av <- anova(model)
Now, I would like to have some multiple comparisons.
Using multcomp
I can do:
require(multcomp)
comp.geno <- glht(model, linfct=mcp(Genotype="Tukey"))
print(summary(comp.geno))
And, of course, I could do the same with time.
I have two questions:
- How do I use
mcp
to see the interaction between Time and Genotype? -
When I run
glht
I get this warning:covariate interactions found -- default contrast might be inappropriate
What does it mean? Can I safely ignore it? Or what should I do to avoid it?
EDIT:
I found this PDF that says:
Because it is impossible to determine the parameters of interest automatically in this case, mcp() in multcomp will by default generate comparisons for the main effects only, ignoring covariates and interactions. Since version 1.1-2, one can specify to average over interaction terms and covariates using arguments interaction_average = TRUE and covariate_average = TRUE respectively, whereas versions older than 1.0-0 automatically averaged over interaction terms. We suggest to the users, however, that they write out, manually, the set of contrasts they want. One should do this whenever there is doubt about what the default contrasts measure, which typically happens in models with higher order interaction terms. We refer to Hsu (1996), Chapter~7, and Searle (1971), Chapter~7.3, for further discussions and examples on this issue.
I do not have access to those books, but maybe someone here has?
Best Answer
If
time
andGenotype
are both categorical predictors as they appear to be, and you are interested in comparing all time/Genotype pairs to each other, then you can just create one interaction variable, and use Tukey contrasts on it:If you are interested in other contrasts, then you can use the fact that the
linfct
argument can take a matrix of coefficients for the contrasts - this way you can set up exactly the comparisons you want.EDIT
There appears some concern in the comments that the model fitted with the
TimeGeno
predictor is different from the original model fitted with theTime * Genotype
predictor. This is not the case, the models are equivalent. The only difference is in the parametrization of the fixed effects, which is set up to make it easier to use theglht
function.I have used one of the built-in datasets (it has Diet instead of Genotype) to demonstrate that the two approaches have the same likelihood, predicted values, etc:
The only difference is that what hypotheses are easy to test. For example, in the first model it is easy to test whether the two predictors interact, in the second model there is no explicit test for this. On the other hand, the joint effect of the two predictors is easy to test in the second model, but not the first one. The other hypotheses are testable, it is just more work to set those up.