Displays the conditional modes ("BLUPs") of a mixed model's random effects as a sorted point-and-interval ("caterpillar") plot. It is the usual way to inspect by-group departures from the average, and to identify unusual groups.
Usage
random_effects_plot(
x,
conf_level = 0.95,
sort = TRUE,
point_colour = depictr_brand(),
title = NULL,
x_lab = "Random effect"
)Arguments
- x
Either a mixed model fitted with 'lme4' (
merMod), or a data frame with one row per group level and columns such aslevel/group,estimate, and eitherconf.low/conf.highorstd.error. An optionaltermcolumn facets the plot.- conf_level
Confidence level when intervals are derived from standard errors.
- sort
Whether to order the levels by their estimate.
- point_colour
Colour for the points and intervals.
- title, x_lab
Plot title and value-axis label.
Value
A ggplot2::ggplot object.
Examples
# From a data frame of by-group estimates:
re <- data.frame(
level = paste0("G", 1:10),
estimate = sort(rnorm(10)),
std.error = runif(10, 0.2, 0.5)
)
random_effects_plot(re)
# \donttest{
if (requireNamespace("lme4", quietly = TRUE)) {
m <- lme4::lmer(RT ~ condition + (1 | participant), data = lexical_decision)
random_effects_plot(m)
}
# }
