Hello,
I am trying to simulate data using the endogenous variables only LISREL model as seen on page 133 of the OpenMx.pdf help documentation. I was able to simulate data from a state space model using the example in the help documentation on page 174. Now I am modifying that piece of code for a LISREL model. However I am running into an error. Below is my code.
library(OpenMx) nvar <- 6 varnames <- paste("x",1:nvar,sep="") ssModelLisrel <- mxModel(model="lisrel", mxMatrix("Full",6,6,TRUE,.2,name="BE"), mxMatrix("Full",6,6,TRUE,.5,name="LY",dimnames=list(varnames,varnames)), mxMatrix("Diag",6,6,FALSE,1,name="PS"), mxMatrix("Diag",6,6,FALSE,1,name="TE"), mxExpectationLISREL(BE="BE",LY="LY",PS="PS",TE="TE"), mxFitFunctionML() ) ssDataLisrel <- mxGenerateData(ssModelLisrel,200)
The error I get is:
Error in mxEvalByName(ALname, model, compute = TRUE, defvar.row = defvar.row) : 'name' argument must be a character argument
Below is my current system configuration:
OpenMx version: 2.5.2 [GIT v2.5.2]
R version: R version 3.1.2 (2014-10-31)
Platform: x86_64-w64-mingw32
Default optimiser: SLSQP
Any assistance would be greatly appreciated! Thank you!
That's not a very friendly or informative error message. Sorry about that! I'll work on generating a better error message for the next release of OpenMx.
It looks like the problem is the model does not have latent means (alpha or AL) or observed intercepts (tau_y or TY). These are needed to generate data. If you're uninterested in these you could simply make them appropriately sized zero matrices.
Thank you very much for your prompt reply! It is greatly appreciated. Unfortunately when I added both the AL and TY matrices, I still got the same error code. I tried giving them both nonzero values but that also didn't work. Here is the code that I was trying to use when I had zero matrices. I also tried using "Zero" instead of "Full" in the mxMatrix function call for these two matrices to no avail.
Again, the error code was the same.
I got a slightly different error message when I added TY and AL matrices. Instead of complaining about a missing 'ALname', it complained about a missing 'KAname'. This led me to find and squash a couple of bugs.
The short story is there was a bug in the data generation for LISREL models. It only impacted endogenous-only models. I just fixed this bug with this commit. Moreover, I added better error messages with this for your first case. Data generation for that case will now produce this:
These changes will be part of the next OpenMx release. In the meantime, data generation for the full LISREL model with means would work. You could also specify the model in terms of
mxPath
statements instead of matrices. It's easy to go back and forth between LISREL and RAM specifications when they are in path form using eithertype='RAM'
ortype='LISREL'
arguments tomxModel
. This example shows a version of the factor model on the OpenMx frontpage specified as a LISREL path model.Sorry about these bugs! Hopefully this is enough to help you get started.
Again, thank you very much for your quick replies as well as your assistance! It is greatly appreciated!
I was able to get a RAM model working using the path formation of the model. Again, thank you very much for your assistance!