I am trying to ensure that my understanding of the random effects in Mixed Effects Models is correct, so I would like to share some R code and the standard deviations in the estimate of the random effect in sequential generalized logistic mixed effects regression models as well as my interpretation to double check with the Cross Validated community.
My understanding of fixed vs. random effects themselves is:
Fixed Effect – Measured effects for which intercepts of the observations will be estimated.
Random Effect – Considered unobserved and normally distributed random variables rather than unknown fixed parameters.
I will make a series of mixed effects models, each with an additional variable, as follows:
library("lme4")
library("titanic")
mod1 <- glmer(Survived ~ (1 | Embarked),
data = titanic_train,
family = binomial,
control = glmerControl(optimizer = "bobyqa"),
nAGQ = 1)
mod2 <- glmer(Survived ~ Pclass + (1 | Embarked),
data = titanic_train,
family = binomial,
control = glmerControl(optimizer = "bobyqa"),
nAGQ = 1)
mod3 <- glmer(Survived ~ Pclass + Sex + (1 | Embarked),
data = titanic_train,
family = binomial,
control = glmerControl(optimizer = "bobyqa"),
nAGQ = 1)
Here "Survived" is the outcome of interest, and I have three models:
- "Embarked" as random effect
- "Embarked" as random effect, Pclass as fixed effect
- "Embarked" as random effect, Pclass and Sex as fixed effects
Now, if I check the standard deviations of the mixed effect (Embarked), I see that they decrease with each additional variable added:
> summary(mod1)$varcor
Groups Name Std.Dev.
Embarked (Intercept) 0.37618
> summary(mod2)$varcor
Groups Name Std.Dev.
Embarked (Intercept) 0.30105
> summary(mod3)$varcor
Groups Name Std.Dev.
Embarked (Intercept) 0.19804
Would it be correct to say that as the standard deviation decreases, it is implied that the covariates being added to the model are more sufficiently explaining the variation in the outcome as compared to the random effects’ estimates?
Or stated differently, the mixed effects begin to appear more "similar" as subsequent covariates are added because the covariates being added explain more of the variation in outcome than do the mixed effects' estimates? The opposite interpretation being that if the standard deviation increased the covariates being added would explain the variation in the outcome less.
If someone could answer these questions, especially with the help of formal logic, I would really appreciate it.