Solved – Multilevel model with nested repeated measures design

lme4-nlmemultilevel-analysisrrepeated measures

I am new with R and I am trying to use multilevel modelling for my dataset using the function glmer (for a binomial outcome variable) and lmer for a continuous one.

I have 4 experimental groups (Treatments) and in each group I am measuring the same outcome variables 4 time for each individual, Conc is binomial (0/1) whilePosQ is continuous
I am treating the variables as: Time =ordered, Conc =Factor with 2 levels, Treatment = Factor with 4 levels, PosQ = Integer (no decimal values) Here is an example of my datafile

ID   Time   Conc   Treatm    PosQ

1    1     1        1       6   
1    2     1        1       12   
1    3     1        1       14  
1    4     1        1       15 
2    1     0        3       20 
2    2     0        3       12
2    3     0        3       8
2    4     0        3       6

It is a 3 level repeated measure design and I want to test the effects of Treatment and Time on my outcome variables.
The variables are nested and not crossed, each individual belong only to 1 of the 4 experimental groups and I made 4 measurement on each individual.
So from the furthest to the nearest Treatment is nested with ID that is nested with Time (express the repeated measurement)

I want to measure the interaction effect of Time and Treatment (I Expect them to be better at the end of the 4 measurement according to the treatment group they belong to and to the pass of time).
I am using multilevel model because I want to take into consideration also individual differences into account
Here are the formulas I was using:

BinomialOutcomeVariable <- glmer(Conc ~ Treatment * Time + (1| Treatm) + (1|Treatm:ID) + (1|Treatm/ID/Time), data = analyses.4, family = binomial(link="logit"))

ContinuousVariable <- lmer(PosQ ~ Treatm * Sequ + (1| Treatm) + (1|Treatm:ID) + (1|Treatm/ID/Time), data = analyses.4)

Are those formulas correct? Can be reduced? because when I run the analyses for continuous variable I receive this warning:

1: number of levels of each grouping factor must be < number of observations

2: grouping factors with < 5 sampled levels may give unreliable estimates

3: In checkConv(attr(opt, "derivs"), opt$par, ctrl = control$checkConv, :
Model is nearly unidentifiable: large eigenvalue ratio
- Rescale variables?

Instead if I use this formula I have no problems for only 1 of the continuous variables

model <- lmer(PosQ ~ Treatm * Time + (1| Treatm/ID), data = analyses.4)

Is the same formula as before?
Does R understand that Time is nested?
If I use isNested function it says that they are not nested.

Any help, idea, suggestion is really appreciated.

Thanks in advance

Best Answer

The only random part here is the individual. Both Time and Treatment are fixed parts. As I understand it, you want global (ie. fixed) estimates of the effect of

  1. Time
  2. Each level of Treatment (except for the reference level)
  3. The interaction between each level of Treatment (except for the reference level) and Time.

The following models will give you that.

fm1 <- lmer(PosQ ~ Treatm * Time + (1|ID), data = analyses.4)
fm2 <- glmer(Conc ~ Treatm * Time + (1|ID), data = analyses.4, family = binomial)

That being said, you can get a random effect of time, ie. a random slope model where the effect of time varies between the individuals.

fm3 <- lmer(PosQ ~ Treatm * Time + (Time|ID), data = analyses.4)
fm4 <- glmer(Conc ~ Treatm * Time + (Time|ID), data = analyses.4, family = binomial)

This is possible since there is within-subject variation with respect to time. However, since there is no within-subject variation with respect to treatment, you cannot do the same for treatment.

Since there is no within-subject variation with respect to treatment, the effect of time in a random slope model is actually the deviance between the individual effect of the particular treatment that the indivdual received and the global estimate of Time, which would measure the average effect of the treatment that corresponds to the reference category of the variable Treatment.

You can use anova() to compare the models and test whether or not it is justified to let the effect of time vary by subject:

anova(fm1, fm3)
anova(fm2, fm4)

would do the testing you need.

Related Question