add_paths {tidySEM} | R Documentation |
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.
add_paths(model, ...)
model |
An object of class |
... |
Paths to add or substitute, specified in
|
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
.
An object of class tidy_sem
.
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)