loading <- matrix(0, 9, 3)
loading[1:3, 1] <- NA
loading[4:6, 2] <- NA
loading[7:9, 3] <- NA
cfamodel <- estmodel(LY=loading, modelType="CFA", indLab=paste("x", 1:9, sep=""))
out <- analyze(cfamodel, HolzingerSwineford1939)
datamodel.nomis <- model.lavaan(out, std=TRUE)
output.nomis <- sim(1000, n=nrow(HolzingerSwineford1939), datamodel.nomis)
summary(output.nomis)
However, the creation of lavaan parameter table is a bit confusing (the definition of 'cfamodel' variable), especially, if for example exogenous variables or regressions are included in SEM model.
My SEM model is as per below. It includes 23 free parameters (5 factor loadings, 9 covariances between latent variable indicators, 3 regressions, 6 variances) and two defined (variance of the latent variable and indirect effect).
FullModel=
"
# Latent variable definition
IWB =~ NOVE+EXPL+TEST+SUPP+IMPL
#Direct effects
IWB ~ OSE
#Medation
IWB ~ g*WE
WE ~ h*OSE
#Indirect effect
gh:=g*h
#Covariances
NOVE ~~ EXPL + SUPP + IMPL
EXPL ~~ TEST + SUPP + IMPL
TEST ~~ SUPP + IMPL
SUPP ~~ IMPL
"
As by the example I would start with:
loading <- matrix(0, 5, 1)
loading[1:5, 1] <- NA
cfamodel <- estmodel(LY=loading, modelType="sem")
But then I have no idea, how to define the rest of the parameters?
I would like to create a data analysis template (lavaan parameter table) for simulations with structural equation models and then perform simulation based on real data.
But then I have no idea, how to define the rest of the parameters?
Yes, the one in github is my question as well. As it was regarding the two simsem package approaches, I thought it was more appropriate to post it there. Apologies if that is not the case.
I have looked at the simsem vignettes, but only found an example of constructing the factor loading matrix (the example I have inserted above is taken from there).
The trouble I have is regarding the specification of the other parameters in a similar way as factor loadings (such as variances or regression coefficients) as I could not find examples in Vignettes (until actually this morning, but even then it was with latent variables, but I would like to do it for observed covariates). I am unfamiliar with LISREL and its syntax therefore I find it a bit confusing.
However as I understand from the answer on https://github.com/simsem/simsem/issues/59
I could avoid specifying LISREL parameter matrices altogether and use the parTable() from the fitted lavaan model in sim() instead and receive the same result, however I receive the error.
--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/2be88cc0-743a-4034-b600-c7257aa76a20%40googlegroups.com.
I could avoid specifying LISREL parameter matrices altogether and use the parTable() from the fitted lavaan model in sim() instead and receive the same result
however I receive the error.
As it was regarding the two simsem package approaches, I thought it was more appropriate to post it there
--
You received this message because you are subscribed to the Google Groups "lavaan" group.
To unsubscribe from this group and stop receiving emails from it, send an email to lavaan+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/lavaan/10967a2b-e8ef-4642-ae67-c770235b163d%40googlegroups.com.