lav2lvnet {lvnet} | R Documentation |
Convert lavaan model to lvnet model matrices
Description
This function can be used to easily generate input matrices for lvnet based on a lavaan model.
Usage
lav2lvnet(model, data, std.lv = TRUE, lavaanifyOps = list(auto = TRUE, std.lv = std.lv))
Arguments
model |
Lavaan model syntax |
data |
The dataset. Only used to extract order of variables names from the columnnames. |
std.lv |
Should the model be identified by constraining latent variable variance to 1. Defaults to |
lavaanifyOps |
A list with other options sent to |
Value
A list with the model matrices for lambda
, psi
, theta
and beta
Author(s)
Sacha Epskamp <mail@sachaepskamp.com>
Examples
## Not run:
library("lavaan")
# Load dataset:
data(HolzingerSwineford1939)
Data <- HolzingerSwineford1939[,7:15]
# lavaan model
HS.model <- '
visual =~ x1 + x2 + x3
textual =~ x4 + x5 + x6
speed =~ x7 + x8 + x9 '
# fit via lavaan:
lavFit <- cfa(HS.model, HolzingerSwineford1939[7:15],std.lv=TRUE)
# Fit via lvnet:
mod <- lav2lvnet(HS.model, HolzingerSwineford1939[7:15])
lvnetFit <- lvnet(Data, lambda = mod$lambda, psi = mod$psi)
# Compare:
Compare <- data.frame(
lvnet = round(unlist(lvnetFit$fitMeasures)[c("npar","df","chisq","fmin","aic","bic",
"rmsea","cfi","tli","nfi","logl")],3),
lavaan = round(fitMeasures(lavFit)[c("npar","df","chisq","fmin","aic","bic","rmsea",
"cfi","tli","nfi","logl")],3))
Compare
## End(Not run)
[Package lvnet version 0.3.5 Index]