[R-sig-ME] Doubts with the syntax in lme4

Mario Garrido gaiarrido at gmail.com
Thu Jun 11 16:01:22 CEST 2015


Dear list

I have got a question regarding the syntax of repeated measures in package
lme4 in R. I have not clear how to define my model using lmer.

I am right now using this syntax


model<-lmer(O2.intake4days~ treatment*daytype*time*age+activity+(1|indiv),
REML = FALSE)


but I guess if I need to add anything to define my within subject factors
that are time of the day (night/day) and day type (before/after).


Am I right in assuming that lmer() automatically differentiates between
within and between subjects factors by indication of the subject variable
(i.e. "individual" in my study) in the term (1|individual) and the fact
that age and treatment do not vary within subjects, whereas time of the day
(night/day) and day type (before/after) do?


I want to know if the O2 consumption of rodents is affected by fleas and
dependent at the same time in other variables as age and treatment
(between-subject variables) and time of the day and day type
(within-subject variables). So, for each individual I got 4 values:

1 during day before treatment

1 during night before treatment

1 during day after treatment

1 during night after treatment



I am working with 42 individuals, 18 juveniles and 24 adults. Among them, 9
juveniles are control and other 9 are treated (as I said, we have added the
fleas just the day after) and 12 ad are control and 12 treated.

I have not clear how to define the model using lmer. I am right now using
this syntax but I guess if I need to add anything to define my within
subject factors as time of the day (dark and night).



model<-lmer(O2.intake4days~ treatment*daytype*time*age+activity+(1|indiv),
REML = FALSE)



Here is a small example of the data



individual                   age                      treatment
          day type       time of the day                    O2 intake

211                         juv
fleas                      before
light                       0.020571

211                         juv
fleas                      after
light                       0.021416

211                         juv
fleas                      before
dark                       0.037797

211                         juv
fleas                      after
dark                       0.039788

213                         juv
control                  before
light                       0.026242

213                         juv
control                  after
light                       0.02446

213                         juv
control                  before                  dark
0.039787

213                         juv
control                  after
dark                       0.039849

23                           ad
control                  before
light                       0.011403

23                           ad
control                  after
light                       0.011588

23                           ad
control                  before                  dark
0.01783

23                           ad
control                  after
dark                       0.015907

36                           ad
fleas                      before
light                       0.011775

36                           ad
fleas                      after
light                       0.01303

36                           ad
fleas                      before
dark                       0.017582

36                           ad
fleas                      after
dark                       0.021021

	[[alternative HTML version deleted]]



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