[R-sig-ME] glmer function in lme4
Bares, Valerie
Valerie.Bares at sdstate.edu
Fri Nov 4 18:11:37 CET 2016
I am utilizing the glmer function in the lme4 package. My data is of longitudinal nature where subjects have one row per month of collected data. My ultimate goal is to create a predictive model off of this data but also want to make inferences off of the generated model. I currently am using glmer to generate a model while using time (months) as a random effect. For example,
glmer(target ~ var1 + (var1|months), family=binomial(link='logit'), data=train)
I initially used glm to create a model for each month separately but wanted to create one model in order to make inferences on variables in the model as related over time. The output from coef() from the above example will give almost identical coefficients to glm(target ~ var1, family=binomial(link='logit'), data=train[which(train$months==i),]), where i represents each separate monthly models.
My questions are:
* Is there a direct relationship between glmer and glm even when using months as a random effect (as shown above).
* It appears that the coefficients from printing the glmer(...) model is just the average of the results from coef(glmer(...)), is this correct?
* How are the coefficients that are conditional on the month variable interpreted? (output from coef(glmer(...)))
* When adding in an additional variable into the model and attempting to generate similar results with glm, the second variable needs to take out the random intercept term to match results, can you explain how and if the following two models are related?
1. glm(target ~ var1 + var2, family=binomial(link='logit'), data=train[which(train$months==i),]), where i represents each separate monthly models
2. glmer(target ~ var1 + var2 + (var1|months) + (0 + var2|months), family=binomial(link='logit'), data=train)
Any insight on this function and how to interpret the output would be greatly appreciated. I can also send the generated output from the above examples if this will help in any explanations.
Thank you,
Valerie Bares
Computation Science and Statistics PhD Candidate
South Dakota State University
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list