Attachment | Size |
---|---|
openmx_forum_lisrel_example.r [6] | 19.84 KB |
I need to compute factor scores which only works in OpenMx if the model type is LISREL. I've attached the model code that includes creating a path diagram for the RAM version. The RAM model code works fine in estimating the parameters. When I convert it to "type="LISREL"", I get various error messages.
This shows the specification for the endogenous and exogenous variables in the LISREL version:
manifestVars=list(
endo=c("c_el","c_nc_el","c_or","c_nc_or",
"c_el_1","c_el_nc_1","c_or_1","c_or_nc_1"),
exo=c("t0s1","t0s2","t0s3","t0s4",
"t1s1","t1s2","t1s3","t1s4",
"t2s1","t2s2","t2s3","t2s4",
"t3s1","t3s2","t3s3","t3s4")
),
latentVars=list(endo=c("mu_e","mu_o"),exo=c("mu_e_1","mu_o_1")),
From the path diagram for the RAM version, it appears (at least to me) that manifest variables t0s1, t0s2, ... , t3s4 are all exogenous and latent variables mu_e_1 and mu_o_1 are exogenous. All the remaining variables are endogenous. Yet when I paste the LISREL model code into R:
Error: non-square MxMatrix attempted in 'nrow' and 'ncol' arguments to mxMatrix(matrixtype, values = values, free = free, labels = labels, name = matrixname)
Not sure where I am going wrong. I also tried to convert from RAM model to a LISREL model by changing the model type to LISREL after saving the RAM model, but this also did not work.
carbon.temp.ar.model.6.mat <- mxModel(carbon.temp.ar.model.6,type="default")
carbon.temp.ar.model.6.lisrel <- mxModel(carbon.temp.ar.model.6.mat,type="LISREL")
But this fails (after a few minutes) when I try to fit the lisrel model:
> mxRun(carbon.temp.ar.model.6.lisrel)
Running Carbon Temperature AR Model 6 with 91 parameters
Error in model@manifestVars$exogenous :
$ operator is invalid for atomic vectors
I was able to obtain a LISREL model version for a simpler related model (no t0s1, etc. variables and only two latent variables mu_e and mu_o) and then compute the factor scores. Although this worked only by specifying ALL of the manifest and latent variables as exogenous.
Obviously, there is something I am missing.