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
Thanks!
Subjectvariable 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. – llewmills Feb 20 '19 at 20:21(1|Subject) + (1|QN/Treatment)? Random effects such as these can be fiendishly confusing. There are so many ways to model them. – llewmills Feb 21 '19 at 03:08