fit <- lme4::lmer(mathach ~ 1 + ses + catholic + (1|id),
data=hsb, REML=TRUE)
# Centering a single variable around the grand mean
fit_gmc <- center(fit, grand_variables="ses")
# Centering multiple variables around the grand mean
fit_gmc <- center(fit, grand_variables=c("ses", "catholic"))
# Centering variables around the group means
fit_cwg <- center(fit, group="id", group_variables="ses")
# Centering variables using different strategies
fit_mixed <- center(fit, group = "id", group_variables = "ses", grand_variables = "catholic")
Run the code above in your browser using DataLab