Skip to content
Prev 11696 / 20628 Next

Help with a mixed model analysis

On 14-03-26 10:25 PM, Rodrigo Junqueira Pereira wrote:
The simplest model might be

weight ~ age*sex+poly(days,2)*treatment + (1|animal)

  However, there are a lot of things you might need to think about.

* I'm not sure what you mean by "the effect of the levels of the ..
treatment ... on the weight trend according to days to calving".
Maybe this is poly(days,2)*treatment, as above (the pattern with respect
to days is quadratic, but the slope and quadratic trend could change
linearly with the treatment).  But maybe you meant that the pattern is
quadratic with respect to the level of treatment?
* If you think the pattern of change with respect to treatment is
complex you might make it a categorical variable (factor), possibly an
ordered factor or a factor with successive-difference contrasts
(MASS::contr.sdif).
* you might also consider generalized additive mixed models (mgcv package)
* in principle any predictor that varies within animal could/should be
considered as interacting with the random effect of animal: in this case
I think you would want (poly(days,2)|animal) instead of (1|animal) (see
Schielzeth and Forstmeier 2009).
See the ?pvalues help page in the lme4 package.