Learn R Programming

performance (version 0.8.0)

check_normality: Check model for (non-)normality of residuals.

Description

Check model for (non-)normality of residuals.

Usage

check_normality(x, ...)

# S3 method for merMod check_normality(x, effects = c("fixed", "random"), ...)

Arguments

x

A model object.

...

Currently not used.

effects

Should normality for residuals ("fixed") or random effects ("random") be tested? Only applies to mixed-effects models. May be abbreviated.

Value

Invisibly returns the p-value of the test statistics. A p-value < 0.05 indicates a significant deviation from normal distribution

Details

check_normality() calls stats::shapiro.test and checks the standardized residuals (or Studentized residuals for mixed models) for normal distribution. Note that this formal test almost always yields significant results for the distribution of residuals and visual inspection (e.g. Q-Q plots) are preferable.

Examples

Run this code
# NOT RUN {
m <<- lm(mpg ~ wt + cyl + gear + disp, data = mtcars)
check_normality(m)

# plot results
if (require("see")) {
  x <- check_normality(m)
  plot(x)
}
# }
# NOT RUN {
# QQ-plot
plot(check_normality(m), type = "qq")

# PP-plot
plot(check_normality(m), type = "pp")
# }

Run the code above in your browser using DataLab