# lme4 model
if (require("lme4") && require("see")) {
model <- lmer(mpg ~ hp + (1 | carb), data = mtcars)
random <- estimate_grouplevel(model)
random
# Visualize random effects
plot(random)
# Show group-specific effects
estimate_grouplevel(model, deviation = FALSE)
# Reshape to wide data so that it matches the original dataframe...
reshaped <- reshape_grouplevel(random, indices = c("Coefficient", "SE"))
# ... and can be easily combined
alldata <- cbind(mtcars, reshaped)
# Use summary() to remove duplicated rows
summary(reshaped)
# Compute BLUPs
estimate_grouplevel(model, type = "total")
}
# Bayesian models
# \donttest{
if (require("rstanarm")) {
model <- rstanarm::stan_lmer(mpg ~ hp + (1 | carb), data = mtcars, refresh = 0)
}
# }
Run the code above in your browser using DataLab