Learn R Programming

multilevelTools (version 0.2.0)

modelDiagnostics.merMod: modelDiagnostics method for merMod objects

Description

This function creates a number of diagnostics for merMod models.

Usage

# S3 method for merMod
modelDiagnostics(
  object,
  ev.perc = 0.001,
  robust = FALSE,
  distr = "normal",
  standardized = TRUE,
  ...
)

Value

A logical (is.modelDiagnostics) or a modelDiagnostics object (list) for

as.modelDiagnostics and

modelDiagnostics.

Arguments

object

A fitted model object, either of class merMod from the lme4 package or merModLmerTest from the lmerTest package.

ev.perc

A real number between 0 and 1 indicating the proportion of the theoretical distribution beyond which values are considered extreme values (possible outliers). Defaults to .001.

robust

Whether to use robust mean and standard deviation estimates for normal distribution

distr

A character string given the assumed distribution. Passed on to testDistribution. Defaults to “normal”.

standardized

A logical whether to use standardized residuals. Defaults to TRUE generally where possible but may depend on method.

...

Additional arguments, passed to residualDiagnostics.

Examples

Run this code

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

md <- modelDiagnostics(m, ev.perc = .1)
md$extremeValues
class(md)

plot(md)

data(aces_daily, package = "JWileymisc")
m <- lme4::lmer(PosAff ~ STRESS + (1 + STRESS | UserID), data = aces_daily)
md <- modelDiagnostics(m, ev.perc = .1)

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

rm(m, md, sleep)

Run the code above in your browser using DataLab