est_change_plot {semfindr} | R Documentation |
Plots of Case Influence on Parameter Estimates
Description
Gets the output of
functions such as est_change()
and
est_change_approx()
and plots case
influence on selected parameters.
Usage
est_change_plot(
change,
parameters,
cutoff_change = NULL,
largest_change = 1,
title = TRUE,
point_aes = list(),
vline_aes = list(),
hline_aes = list(),
cutoff_line_aes = list(),
case_label_aes = list(),
wrap_aes = list()
)
est_change_gcd_plot(
change,
parameters,
cutoff_gcd = NULL,
largest_gcd = 1,
cutoff_change = NULL,
largest_change = 1,
title = TRUE,
point_aes = list(),
hline_aes = list(),
cutoff_line_aes = list(),
case_label_aes = list(),
wrap_aes = list()
)
Arguments
change |
The output from
|
parameters |
If it is
a character vector, it
specifies the selected parameters.
Each parameter is named as in
|
cutoff_change |
Cases with
absolute changes larger than this
value will be labeled. Default is
|
largest_change |
The number of cases with the largest absolute changes to be labelled. Default is
|
title |
If |
point_aes |
A named list of
arguments to be passed to
|
vline_aes |
A named list of
arguments to be passed to
|
hline_aes |
A named list of
arguments to be passed to
|
cutoff_line_aes |
A named list
of arguments to be passed to
|
case_label_aes |
A named list of
arguments to be passed to
|
wrap_aes |
A named list of
arguments to be passed to
|
cutoff_gcd |
Cases with
generalized Cook's distance or
approximate generalized Cook's
distance larger than this value will
be labeled. Default is |
largest_gcd |
The number of cases with the largest generalized Cook's distance or approximate generalized Cook's distance to be labelled. Default is 1. If not an integer, it will be rounded to the nearest integer. |
Details
The output of
est_change()
, est_change_raw()
,
est_change_approx()
, and
est_change_raw_approx()
is simply a
matrix. Therefore, these functions
will work for any matrix provided.
Row number will be used on the x-axis
if applicable. However, case
identification values will be used
for labeling individual cases if they
are stored as row names.
The default settings for the plots
should be good enough for diagnostic
purpose. If so desired, users can
use the *_aes
arguments to nearly
fully customize all the major
elements of the plots, as they would
do for building a ggplot2 plot.
Value
A ggplot2 plot. Plotted by
default. If assigned to a variable or
called inside a function, it will not
be plotted. Use plot()
to plot it.
Functions
-
est_change_plot()
: Index plot of case influence on parameters. -
est_change_gcd_plot()
: Plot case influence on parameter estimates against generalized Cook's distance.
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
est_change()
,
est_change_raw()
,
est_change_approx()
, and
est_change_raw_approx()
.
Examples
library(lavaan)
# A path model
dat <- pa_dat
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)
# Compute approximate case influence on parameters estimates
out <- est_change_approx(fit)
# Plot case influence for all regression coefficients
est_change_plot(out,
parameters = "~",
largest_change = 2)
# Plot case influence against approximated gCD for all
# regression coefficients
# Label top 5 cases with largest approximated gCD
est_change_gcd_plot(out,
parameters = "~",
largest_gcd = 5)
# Customize elements in a plot.
# For example, change the color and shape of the points.
est_change_plot(out,
parameters = "~",
largest_change = 2,
point_aes = list(shape = 5,
color = "red"))