5
$\begingroup$

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

$\endgroup$
6
  • $\begingroup$ I'm not very familiar with the 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, so lmer(PosQ ~ Treatm * Time + (1| Treatm/ID), data = analyses.4). $\endgroup$ Commented Nov 5, 2015 at 15:05
  • $\begingroup$ Thanks BlankUsername, May I ask you why? $\endgroup$
    – BobStat
    Commented Nov 5, 2015 at 15:07
  • $\begingroup$ Well I'm not entirely sure but it seems to be the wrong syntax (see ?lmer for instance). $\endgroup$ Commented Nov 5, 2015 at 15:10
  • $\begingroup$ Could you explain a bit more about what you're actually analysing? Because I have read it a couple of times now, but am still puzzled. For instance, how many individuals are we're talking about here, and what does your outcome variables actually measure, and what is the difference between the treatments? I ask because from the data snapshot you provide there seems to be very little variation. I mean for ID 1 and 2 they receive the same treatment in all the time periods. Maybe I am missing something obvious here. $\endgroup$ Commented Nov 5, 2015 at 15:25
  • $\begingroup$ @BlankUsername I have 48 participants and 4 measurement for each so altogether 192 measurements, Yes each participant receive the same treatment along the four measurements, basically each treatment creates an experimental group, the difference is in the type of feedback provided. I am measuring if feedback and time improve the quality of interviews made by an interviewer, and I am measuring the quality of interviews $\endgroup$
    – BobStat
    Commented Nov 5, 2015 at 16:27

1 Answer 1

8
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.