add_paths: Add paths to an object of class 'tidy_sem'

View source: R/syntax-add_paths.R

add_pathsR Documentation

Add paths to an object of class 'tidy_sem'

Description

Add paths to an object of class tidy_sem, or replace existing paths. The paths must be specified as model.syntax, and separated by commas.

Usage

add_paths(model, ...)

Arguments

model

An object of class tidy_sem.

...

Paths to add or substitute, specified in lavaan{model.syntax}, and separated by commas.

Details

Currently, only the lavaan{lavaan} commands ~, ~~, =~, and ~1 are parsed.

This function relies on lavaan model.syntax to convert syntax strings to lavaan parameter tables. By default, is uses the arguments int.ov.free = TRUE, int.lv.free = FALSE, auto.fix.first = TRUE, auto.fix.single = TRUE, auto.var = TRUE, auto.cov.lv.x = TRUE, auto.efa = TRUE, auto.th = TRUE, auto.delta = TRUE, auto.cov.y = TRUE, meanstructure = TRUE, in a similar way to sem and cfa.

Value

An object of class tidy_sem.

See Also

model.syntax

Examples

library(lavaan)
df <- iris[, 1:4]
names(df) <- paste0("x_", 1:4)
model <- tidy_sem(df)
model <- measurement(model)
model <- add_paths(model, x =~ a*x_1 + b*x_2 + a*x_3 + b*x_4)
res <- estimate_lavaan(model)
summary(res)

tidySEM documentation built on Oct. 25, 2023, 1:06 a.m.