influence_stat {semfindr}R Documentation

Case Influence Measures

Description

Gets a lavaan_rerun() output and computes the changes in selected parameters and fit measures for each case if included.

Usage

influence_stat(
  rerun_out,
  fit_measures = c("chisq", "cfi", "rmsea", "tli"),
  baseline_model = NULL,
  parameters = NULL,
  mahalanobis = TRUE,
  keep_fit = TRUE
)

Arguments

rerun_out

The output from lavaan_rerun(), or the output of lavaan::lavaan() or its wrappers (e.g., lavaan::cfa() and lavaan::sem()).

fit_measures

The argument fit.measures used in lavaan::fitMeasures. Default is c("chisq", "cfi", "rmsea", "tli").

baseline_model

The argument baseline.model used in lavaan::fitMeasures. Default is NULL.

parameters

A character vector to specify the selected parameters. Each parameter is named as in lavaan syntax, e.g., x ~ y or x ~~ y, as appeared in the columns lhs, op, and rhs in the output of lavaan::parameterEstimates(). Supports specifying an operator to select all parameters with this operators: ~, ⁠~~⁠, ⁠=~⁠, and ~1. This vector can contain both parameter names and operators. More details can be found in the help of pars_id(). If omitted or NULL, the default, changes on all free parameters will be computed.

mahalanobis

If TRUE, it will call mahalanobis_rerun() to compute the Mahalanobis distance. Default is TRUE.

keep_fit

If TRUE, it will keep the original lavaan output using the full sample as an attribute to the output. It can be used by other functions to extract necessary information. Default is TRUE.

Details

For each case, influence_stat() computes the differences in the estimates of selected parameters and fit measures with and without this case. Users can also request a measure of extremeness (only Mahalanobis distance is available for now).

If rerun_out is the output of lavaan_rerun(), it will use the leave-one-out approach. Measures are computed by est_change() and fit_measures_change().

If rerun_out is the output of lavaan::lavaan() or its wrappers (e.g., lavaan::cfa() or lavaan::sem()), it will use the approximate approach. Measures are computed by est_change_approx() and fit_measures_change_approx().

If Mahalanobis distance is requested, it is computed by mahalanobis_rerun().

Please refer to the help pages of the above functions on the technical details.

Supports both single-group and multiple-group models. (Support for multiple-group models available in 0.1.4.8 and later version).

Value

An influence_stat-class object, which is a matrix with the number of columns equals to the number of requested statistics, and the number of rows equals to the number of cases. The row names are the case identification values used in lavaan_rerun(). Please refer to the help pages of est_change() and fit_measures_change() (or est_change_approx() and fit_measures_change_approx() for details. This object has a print method for printing user-friendly output.

Author(s)

Shu Fai Cheung https://orcid.org/0000-0002-9871-9448.

References

Pek, J., & MacCallum, R. (2011). Sensitivity analysis in structural equation models: Cases and their influence. Multivariate Behavioral Research, 46(2), 202-228. doi:10.1080/00273171.2011.561068

See Also

fit_measures_change(), est_change(), and mahalanobis_rerun().

Examples

library(lavaan)
dat <- pa_dat
# The model
mod <-
"
m1 ~ a1 * iv1 + a2 * iv2
dv ~ b * m1
a1b := a1 * b
a2b := a2 * b
"
# Fit the model
fit <- lavaan::sem(mod, dat)
summary(fit)

# --- Leave-One-Out Approach

# Fit the model n times. Each time with one case removed.
# For illustration, do this only for selected cases.
fit_rerun <- lavaan_rerun(fit, parallel = FALSE,
                          to_rerun = 1:10)
# Get all default influence stats
out <- influence_stat(fit_rerun)
head(out)

# --- Approximate Approach

out_approx <- influence_stat(fit)
head(out_approx)


[Package semfindr version 0.1.8 Index]