Learn R Programming

HLMdiag (version 0.5.0)

hlm_influence.default: Calculating influence diagnostics for HLMs

Description

This function is used to compute influence diagnostics for a hierarchical linear model. It takes a model fit as a lmerMod object or as a lme object and returns a tibble with Cook's distance, MDFFITS, covtrace, covratio, and leverage.

Usage

# S3 method for default
hlm_influence(model, ...)

# S3 method for lmerMod hlm_influence( model, level = 1, delete = NULL, approx = TRUE, leverage = "overall", data = NULL, ... )

# S3 method for lme hlm_influence( model, level = 1, delete = NULL, approx = TRUE, leverage = "overall", ... )

Arguments

model

an object of class lmerMod or lme

...

not in use

level

used to define the group for which cases are deleted and influence diagnostics are calculated. If level = 1 (default), then influence diagnostics are calculated for individual observations. Otherwise, level should be the name of a grouping factor as defined in flist for a lmerMod object or as in groups for a lme object.

delete

numeric index of individual cases to be deleted. If the level parameter is specified, delete may also take the form of a character vector consisting of group names as they appear in flist for lme4 models or as in groups for nlme models. If delete = NULL then all cases are iteratively deleted.

approx

logical parameter used to determine how the influence diagnostics are calculated. If FALSE (default), influence diagnostics are calculated using a one step approximation. If TRUE, influence diagnostics are calculated by iteratively deleting groups and refitting the model using lmer. This method is more accurate, but slower than the one step approximation. If approx = FALSE, the returned tibble also contains columns for relative variance change (RVC).

leverage

a character vector to determine which types of leverage should be included in the returned tibble. There are four options: 'overall' (default), 'fixef', 'ranef', or 'ranef.uc'. One or more types may be specified. For additional information about the types of leverage, see ?leverage.

data

(optional) the data frame used to fit the model. This is only necessary for lmerMod models if na.action = "na.exclude" was set.

Details

The hlm_influence function provides a wrapper that appends influence diagnostics to the original data. The approximated influence diagnostics returned by this function are equivalent to those returned by cooks.distance, mdffits, covtrace, covratio, and leverage. The exact influence diagnostics obtained through a full refit of the data are also available through case_delete and the accompanying functions cooks.distance, mdffits, covtrace, and covratio that can be called directly on the case_delete object.