lm_from_lavaan_list: 'lavaan'-class to 'lm_from_lavaan_list'-Class

View source: R/lavaan2lm_list.R

lm_from_lavaan_listR Documentation

'lavaan'-class to 'lm_from_lavaan_list'-Class

Description

Converts the regression models in a lavaan-class model to an lm_from_lavaan_list-class object.

Usage

lm_from_lavaan_list(fit)

Arguments

fit

A lavaan-class object, usually the output of lavaan::lavaan() or its wrappers.

Details

It identifies all dependent variables in a lavaan model and creates an lm_from_lavaan-class object for each of them.

This is an advanced helper used by plot.cond_indirect_effects(). Exported for advanced users and developers.

Value

An lm_from_lavaan_list-class object, which is a list of lm_from_lavaan objects. It has a predict-method (predict.lm_from_lavaan_list()) for computing the predicted values from one variable to another.

See Also

predict.lm_from_lavaan_list

Examples

library(lavaan)
data(data_med)
mod <-
"
m ~ a * x + c1 + c2
y ~ b * m + x + c1 + c2
"
fit <- sem(mod, data_med, fixed.x = FALSE)
fit_list <- lm_from_lavaan_list(fit)
tmp <- data.frame(x = 1, c1 = 2, c2 = 3, m = 4)
predict(fit_list, x = "x", y = "y", m = "m", newdata = tmp)


manymome documentation built on Oct. 4, 2024, 5:10 p.m.