residualDiagnostics.merMod: residualDiagnostics methods for merMod objects

View source: R/diagnostics.R

residualDiagnostics.merModR Documentation

residualDiagnostics methods for merMod objects

Description

residualDiagnostics methods for merMod objects

Usage

## S3 method for class 'merMod'
residualDiagnostics(
  object,
  ev.perc = 0.001,
  robust = FALSE,
  distr = "normal",
  standardized = TRUE,
  cut = 8L,
  quantiles = TRUE,
  ...
)

Arguments

object

An object with class merMod. Currently only lmer() models are supported.

ev.perc

The extreme value percentile to use. Defaults to .001.

robust

A logical value, whether to use robust estimates or not. Defaults to FALSE.

distr

A character string specifying the assumed distribution. Currently “normal”, but may expand in the future if glmer() models are supported.

standardized

A logical value whether to use standardized residual values or not. Defaults to TRUE.

cut

An integer, how many unique predicted values there have to be at least for predicted values to be treated continuously, otherwise they are treated as discrete values. Defaults to 8.

quantiles

A logical whether to calculate quantiles for the residuals. Defaults to TRUE. If FALSE, then do not calculate them. These are based on simple quantiles for each predicted value if the predicted values are few enough to be treated discretely. See cut argument. Otherwise they are based on quantile regression. First trying smoothing splines, and falling back to linear quantil regression if the splines fail. You may also want to turn these off if they are not working well, or are not of value in your diagnostics.

...

Additional arguments. Not currently used.

Value

A logical (is.residualDiagnostics) or a residualDiagnostics object (list) for as.residualDiagnostics and residualDiagnostics.

Examples

library(JWileymisc)
sleep[1,1] <- NA
m <- lme4::lmer(extra ~ group + (1 | ID), data = sleep)

residualDiagnostics(m)$Residuals

#  gm1 <- lme4::glmer(cbind(incidence, size - incidence) ~ period + (1 | herd),
#    data = lme4::cbpp, family = binomial)
# residualDiagnostics(gm1) ## should be an error

rm(m, sleep)


multilevelTools documentation built on April 13, 2025, 9:08 a.m.