I have an experiment where subjects reported multiple results (binary) in two treatments. I have compared each subject separately to see if the treatment had an effect on a given subject, but would also like to compare the data as a whole. I have gone with a Generalized Linear Mixed Effects Model (I have never done this type of analysis before).

I'm using the lme4 package in R and the glmer function, and I want to see the effect the treatment has on the results, so I have done the following:

model <- glmer(Response ~ Treatment + (Treatment|Subject), data=data, family=binomial(link=logit))

So the model puts the treatment as the fixed effect and takes into account the difference in the treatment for each subject as the random effect. I am then looking at the significance of the treatment in the model. Does that make sense or am I off my rocker?

Model output:

Fixed Effects:

                   Estimate   Std. Error   z value    PR(>|z|)
(Intercept)       -1.5066     0.2466       -6.109     1e-09 ***
Treatment         -0.6620     0.2803       -2.362     0.0182*

Random Effects:

                   Groups   Name        Variance   Std.Dev.  Corr
                   Subject  (Intercept) 0.4085     0.6391    
                            Treatment   0.002103   0.04585   -1.00


  • 1
    $\begingroup$ Makes sense to me. I may possible worry about overfitting by including treatment as a random effect in addition to the fixed effect. Does the fixed effect estimate significantly change if you remove it as a random effect? Also that corr estimate of -1 seems odd. $\endgroup$ – Glen Feb 20 at 20:20
  • 1
    $\begingroup$ Is the difference in treatment amongst participants really random or is it just that you are randomising them? If the latter then I don't think you need to make treatment a random effect, as the Subject variable takes care or that. Try making another model with (1|Subject) as the random effect. Then perform a likelihood ratio test (anova(model1, model2)). If the model without the trestment random effect is the same of superior then use that. Also if this is a repeated measures design you should probably account for those repeats in the fixed effects part of the model somewhere. $\endgroup$ – llewmills Feb 20 at 20:21
  • 1
    $\begingroup$ I think your model is overparameterized as @llewmills mentions. See here: stats.stackexchange.com/questions/323273/…. If the order of treatments were randomized then include that order term as a fixed effect. $\endgroup$ – Glen Feb 20 at 20:30
  • 1
    $\begingroup$ Oh i see so it sounds like `treatment' already is the repeated measures fsctor (it has multiple levels i gather, and a single subject can be observed at some or all of those levels?). If so I think your model might be good to go $\endgroup$ – llewmills Feb 20 at 20:40
  • 1
    $\begingroup$ Yes I would suggest adding treatment*position. $\endgroup$ – Glen Feb 20 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.