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 estimator argument of lavaan::lavaan() and its wrappers, such as lavaan::sem() and lavaan::cfa().

fit_list

The output of compare_estimators().

reference

The name of the reference method (ratios will be equal to one). Must be one of the estimator used on compare_estimators(). If NULL, the first estimator will be used.

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

Author(s)

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

See Also

group_by_models()

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")


[Package semhelpinghands version 0.1.11 Index]