View source: R/influence_stat.R
influence_stat | R Documentation |
Gets a lavaan_rerun()
output and computes the changes
in selected parameters and fit measures for each case if included.
influence_stat(
rerun_out,
fit_measures = c("chisq", "cfi", "rmsea", "tli"),
baseline_model = NULL,
parameters = NULL,
mahalanobis = TRUE,
keep_fit = TRUE
)
rerun_out |
The output from |
fit_measures |
The argument |
baseline_model |
The argument |
parameters |
A character vector to specify the selected
parameters. Each parameter is named as in |
mahalanobis |
If |
keep_fit |
If |
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).
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.
Shu Fai Cheung https://orcid.org/0000-0002-9871-9448.
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
fit_measures_change()
, est_change()
, and mahalanobis_rerun()
.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.