[R-sig-ME] Help with a mixed model analysis

Ben Bolker bbolker at gmail.com
Thu Mar 27 04:01:26 CET 2014


On 14-03-26 10:25 PM, Rodrigo Junqueira Pereira wrote:
> Dear all.
> 
> I’m new on lme4 package and I would like to run a mixed model
> analysis on repeated measures longitudinal data. I have the following
> data.frame with the columns:
> 
> weight: weight of the animal; sex: sex of the calf (2 classes); age:
> age of the animal; treatment: level of a protein supplement (levels:
> 0, 0.5, 1, 1.5, 2); day: days to calving of the animal;
> 
> I would like to study the effect of the levels of the protein
> supplement (treatment) on the weight trend (quadratic regression)
> according to days to calving. However, is important to consider the
> additional fixed effects of the sex of the calf and the age of the
> animal (linear regression: intercept + slope) on the weight.
> 
> I have unequal number of replicates by treatment and unequal number
> of records by animal.
> 
> Could anyone help me with the model syntax on lme4 package?

  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).

> 
> Is it possible to get p-values for treatment comparisons?

  See the ?pvalues help page in the lme4 package.

> 
> —— Rodrigo. _______________________________________________ 
> R-sig-mixed-models at r-project.org mailing list 
> https://stat.ethz.ch/mailman/listinfo/r-sig-mixed-models
>



More information about the R-sig-mixed-models mailing list