This function accepts a model as input, and returns a model as output where all the RAM objective functions have been transformed to either ML or FIML objective functions, where the necessary algebras have been auto-generated in order to calculate the expected covariance and means matrices.

omxRAMtoML(model)

model a MxModel object.

# Read libraries and set options. require(OpenMx) # ---------------------------------- # Read the data and print descriptive statistics. data(factorExample1) # ---------------------------------- # Build an OpenMx single factor FIML model with fixed variance indicators <- names(factorExample1) latents <- c("F1") loadingLabels <- paste("b_", indicators, sep="") uniqueLabels <- paste("U_", indicators, sep="") meanLabels <- paste("M_", indicators, sep="") factorVarLabels <- paste("Var_", latents, sep="") oneFactorRaw1 <- mxModel("Single Factor FIML Model with Fixed Variance", type="RAM", manifestVars=indicators, latentVars=latents, mxPath(from=latents, to=indicators, # arrows=1, all=TRUE, arrows=1, connect="all.pairs", free=TRUE, values=.2, labels=loadingLabels), mxPath(from=indicators, arrows=2, free=TRUE, values=.8, labels=uniqueLabels), mxPath(from=latents, arrows=2, free=FALSE, values=1, labels=factorVarLabels), mxPath(from="one", to=indicators, arrows=1, free=TRUE, values=.1, labels=meanLabels), mxData(observed=factorExample1, type="raw") ) oneFactorRawML <- omxRAMtoML(oneFactorRaw1) oneFactorRawMLOut <- mxRun(oneFactorRawML, suppressWarnings=TRUE)# See the results...summary(oneFactorRawMLOut) data: $`Single Factor FIML Model with Fixed Variance.data` x1 x2 x3 x4 Min. :-2.99780 Min. :-1.579400 Min. :-2.13250 Min. :-3.00650 1st Qu.:-0.62555 1st Qu.:-0.365850 1st Qu.:-0.26977 1st Qu.:-0.69588 Median :-0.03170 Median : 0.007300 Median : 0.05055 Median :-0.04330 Mean :-0.01161 Mean :-0.006821 Mean : 0.02396 Mean :-0.03135 3rd Qu.: 0.59815 3rd Qu.: 0.333675 3rd Qu.: 0.33495 3rd Qu.: 0.68142 Max. : 2.54270 Max. : 1.800600 Max. : 1.26530 Max. : 2.88340 x5 x6 x7 x8 Min. :-3.20380 Min. :-3.54670 Min. :-4.15680 Min. :-2.05160 1st Qu.:-0.71252 1st Qu.:-0.98603 1st Qu.:-1.07967 1st Qu.:-0.64263 Median :-0.02015 Median :-0.07750 Median :-0.14610 Median :-0.05310 Mean :-0.04548 Mean :-0.09178 Mean :-0.06732 Mean :-0.03902 3rd Qu.: 0.62877 3rd Qu.: 0.77910 3rd Qu.: 0.91097 3rd Qu.: 0.58552 Max. : 2.85080 Max. : 3.26040 Max. : 3.74800 Max. : 2.63280 x9 Min. :-3.68950 1st Qu.:-0.83327 Median :-0.04285 Mean :-0.05999 3rd Qu.: 0.72447 Max. : 3.47750 free parameters: name matrix row col Estimate Std.Error lbound ubound 1 b_x1 A x1 F1 0.68395558 0.03517218 2 b_x2 A x2 F1 0.32481984 0.02238500 3 b_x3 A x3 F1 0.10886694 0.02076627 4 b_x4 A x4 F1 0.47440890 0.04457067 5 b_x5 A x5 F1 0.60180412 0.04221052 6 b_x6 A x6 F1 1.12063877 0.04569668 7 b_x7 A x7 F1 1.25933139 0.04883099 8 b_x8 A x8 F1 0.64739267 0.03057637 9 b_x9 A x9 F1 0.71872734 0.04926900 10 U_x1 S x1 x1 0.35279611 0.02484526 11 U_x2 S x2 x2 0.17619283 0.01193414 12 U_x3 S x3 x3 0.19353556 0.01230270 13 U_x4 S x4 x4 0.79987497 0.05201061 14 U_x5 S x5 x5 0.63305704 0.04272612 15 U_x6 S x6 x6 0.36762720 0.03207912 16 U_x7 S x7 x7 0.34023767 0.03483551 17 U_x8 S x8 x8 0.23403773 0.01730076 18 U_x9 S x9 x9 0.85441146 0.05777368 19 M_x1 M 1 x1 -0.01161303 0.04050289 20 M_x2 M 1 x2 -0.00682285 0.02373273 21 M_x3 M 1 x3 0.02396104 0.02026669 22 M_x4 M 1 x4 -0.03135672 0.04527295 23 M_x5 M 1 x5 -0.04548168 0.04460893 24 M_x6 M 1 x6 -0.09178376 0.05696533 25 M_x7 M 1 x7 -0.06732317 0.06204879 26 M_x8 M 1 x8 -0.03902037 0.03613431 27 M_x9 M 1 x9 -0.05999675 0.05235709 observed statistics: 4500 estimated parameters: 27 degrees of freedom: 4473 -2 log likelihood: 9706.388 saturated -2 log likelihood: NA number of observations: 500 chi-square: NA p: NA Information Criteria: df Penalty Parameters Penalty Sample-Size Adjusted AIC 760.3878 9760.388 NA BIC -18091.5542 9874.182 9788.483 CFI: NA TLI: NA RMSEA: NA

Please add material here as you learn... If you have questions not answers, then add those here: That's how a wiki works.

- Log in or register to post comments
- Talk
- Printer-friendly version

## Comments

## utilization of created matrices

How can one use the matrices created by omxRAMtoML with the mxFIMLObjective?

mraw is my model as RAM.

When I use mrawML$covariance@name and mrawML$covariance@name as expected covariance and expected means, respectively, I get the error at the end of this post:

> mrawML <- omxRAMtoML(mraw)

> FIMLobjective <- mxFIMLObjective(covariance=mrawML$covariance@name,means=mrawML$means@name,dimnames=Namen)

>

> mrawMLwithFIML <- mxModel('Modell SES FIML', mraw, FIMLobjective)

>

> FitrawFIML <- mxRun(mrawMLwithFIML)

Running Modell SES FIML

Error: Unknown expected covariance name 'covariance' detected in the objective function of model 'Modell SES FIML'

>

Thanks in advance for any help!

## In the future, I recommend

In the future, I recommend posting your questions to the forums. New forum posts are noticed much faster than new comments to a wiki page. With regards to the issue at hand, you'll need to include the original model as the 1st argument to the mxModel() function in order to modify the existing model. As currently specified, you are constructing a new model with the objective function and data but it is missing all of the other matrices and algebras. Use the function mxRename() to give the model a new name, it will correct any internal references from the old name to the new name. I would write it as follows:

In playing around with this example, I found that omxRAMtoML() has a bug and incorrectly throws an error if the input model has data with type='cov'. This will be corrected in OpenMx 1.2.5.