View source: R/syntax-add_paths.R
add_paths | R Documentation |
Add paths to an object of class tidy_sem
, or replace
existing paths. The paths must be specified as
lavaan::model.syntax, and separated by commas.
add_paths(model, ...)
model |
An object of class |
... |
Paths to add or substitute, specified in lavaan::model.syntax, and separated by commas. |
Currently, only the 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 lavaan::sem()
and lavaan::cfa()
.
An object of class tidy_sem
.
lavaan::model.syntax
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.