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, ...)

Arguments

model

An object of class tidy_sem.

...

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

Value

An object of class tidy_sem.

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, akin to sem and cfa.

See also

Examples

#> This is lavaan 0.6-9 #> lavaan is FREE software! Please report any bugs.
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)
#> Warning: lavaan WARNING: some estimated ov variances are negative
summary(res)
#> lavaan 0.6-9 ended normally after 42 iterations #> #> Estimator ML #> Optimization method NLMINB #> Number of model parameters 8 #> Number of equality constraints 1 #> #> Number of observations 150 #> #> Model Test User Model: #> #> Test statistic 356.543 #> Degrees of freedom 3 #> P-value (Chi-square) 0.000 #> #> Parameter Estimates: #> #> Standard errors Standard #> Information Expected #> Information saturated (h1) model Structured #> #> Latent Variables: #> Estimate Std.Err z-value P(>|z|) #> x =~ #> x_1 1.000 #> x_2 0.948 0.052 18.314 0.000 #> x_3 2.499 0.121 20.569 0.000 #> x_4 0.948 0.052 18.314 0.000 #> #> Variances: #> Estimate Std.Err z-value P(>|z|) #> .x_1 0.175 0.021 8.334 0.000 #> .x_2 0.923 0.106 8.742 0.000 #> .x_3 -0.065 0.041 -1.585 0.113 #> .x_4 0.053 0.008 6.359 0.000 #> x 0.506 0.076 6.639 0.000 #> #> Constraints: #> |Slack| #> .p2. - (.p4.) 0.000 #>