res_norm(), res_fit(), and res_box() provide diagnostic plots to check
model assumptions at the within-group level for linear mixed-effects models
fitted with lme4::lmer(). These checks are applicable to all valid lmer
model structures (no shorthand syntax), including complex nested and crossed
random structure.
Arguments
- model
A fitted model object from
lme4::lmer(). Currently not supporting formula that contains shorthand., such asy ~ ..- group_var
A character value specifying the name of the grouping variable. Must be a valid random intercept in
modeland a valid variable in the data used.
Checking Assumptions
res_norm()generates a quantile-quantile (QQ) plot of the Pearson residuals to assess normality within groups.res_fit()plots Pearson residuals against fitted values to detect funnel shapes or mean-variance trends that suggest transformation issues.res_box()creates a boxplot of residuals grouped by a specified random intercept grouping variable to visually inspect heteroscedasticity.
These plots help detect violations of within-group assumptions in mixed-effect models (normality, homoscedasticity, independence), which are central to valid inference in hierarchical models. Between-group assumption checks are not included here, due to the various natures of complex random structures.



