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
lme4
package but your first model specification does not seem to be correct. You should only specific the multilevel structure once, as you did in the second specification, solmer(PosQ ~ Treatm * Time + (1| Treatm/ID), data = analyses.4)
. $\endgroup$?lmer
for instance). $\endgroup$ID
1 and 2 they receive the same treatment in all the time periods. Maybe I am missing something obvious here. $\endgroup$