compare_estimators {semhelpinghands} | R Documentation |
Refit a 'lavaan'-Model by Several Estimators
Description
Refit a model in 'lavaan' by several lavaan-supported estimators
Usage
compare_estimators(object, estimators = NULL)
se_ratios(fit_list, reference = NULL)
Arguments
object |
A lavaan object. |
estimators |
A character vector
of the estimator supported by the
|
fit_list |
The output
of |
reference |
The name
of the reference method
(ratios will be equal to one).
Must be one of the estimator
used on |
Details
The function simply uses
lapply()
and update()
to rerun
the analysis once for each of the
estimator using update(object, estimator = "x"
, x
being the
estimator.
The results can then be compared
using group_by_models()
.
Value
A list of lavaan
outputs,
each of them is an update of the
original output using one of the
estimators.
Functions
-
compare_estimators()
: Refit the model with different estimators. -
se_ratios()
: A wrapper ofgroup_by_models()
that computes the ratios of standard errors of different methods to those of one method.
Author(s)
Shu Fai Cheung https://orcid.org/0000-0002-9871-9448.
See Also
Examples
library(lavaan)
set.seed(5478374)
n <- 50
x <- runif(n) - .5
m <- .40 * x + rnorm(n, 0, sqrt(1 - .40))
y <- .30 * m + rnorm(n, 0, sqrt(1 - .30))
dat <- data.frame(x = x, y = y, m = m)
model <-
'
m ~ a*x
y ~ b*m
ab := a*b
'
fit <- sem(model, data = dat, fixed.x = FALSE)
# Refit the model by three different estimators
fit_more <- compare_estimators(fit, estimator = c("GLS", "MLR", "ML"))
# Use group_by_models to compare the estimates
group_by_models(fit_more, col_names = c("est", "pvalue"))
# Use se_ratios to compare standard errors
se_ratios(fit_more, reference = "ML")