Here's a beta of a new function to get standardized output from a RAM model. I've only tested it on one or two models, so I'd love some help breaking it. You have to either supply a model that uses mxRAMObjective or you have to supply the names of the A and S matrices.

Edit (11/1/10): Previous version standardized S correctly but A incorrectly. Fixed. Also improved some error messages.

Edit (12/13/10): Previous version correctly standardized model and matrix output, but incorrectly standardized A matrix on 'parameters' output. Fixed. Reminder that when using 'model' output, only the model matrices are affected: the matrices in the 'output' slot are not affected, as that would require changing model optimization information.

Attachment | Size |
---|---|

standardizeRAM.R | 3.07 KB |

Hi Ryne: This will be very helpful for people!

Question: Shouldn't

rescale <- invSDs[as.numeric(p$row)] * invSDs[as.numeric(p$col)]

be

rescale <- invSDs[p$row] * invSDs[p$col]

Best, wishes

t

You're right. I did that as a work-around to mxSummary, which returned the row names as numeric 1:4 and column names as characters 1:4. I now realize that won't work if someone actually specifies dimnames for their A and S matrices. I added a patch that gives the invSDs default names of the numbers 1:length(invSDs) as characters, so that invSDs[1] and invSDs["1"] both work. However, if there are dimnames on the columns of the A matrix, those are populated instead. I'm choosing not to check whether the dimnames of A and the dimnames of S are identical, because they're usually either NULL or autopopulated to be equal through type="RAM". One would have to manually set A and S to have different dimnames.

I might as well describe the function a little better. The primary argument is an existing model to be standardized. If it is type="RAM" or uses the mxRAMObjective, you don't have to do anything else. If you don't use the RAM objective (say, you use an algebra to to the RAM matrices), you have to supply the names (as character strings) of the A and S matrices. The output (varied by the argument 'return') is either an mxSummary-style list of standardized parameters and standard errors (return="parameters"), the standardized matrices (return="matrices") or a model with the standardized A and S matrices populated (return="model").

The last option also returns a standardized M matrix, which is all zeros by definition, whereas the parameters and matrices options don't return the M matrices or their free parameters. It should be noted that return="model" only changes the model matrices; no changes are made to the 'output' slot of a returned model, summary(standardizeRAM(model)) will look exactly like summary(model). If you want a standardized parameter list a la summary, use standardizeRAM(model).

gone?

Drupal freaked out a bit. Here's the function.

Hi. What am I doing wrong? I'm using FIML. I supply the matrix names:

> standardizeRAM(Fit4238,Amat=Fit4238@output$matrices$s4238.A,Smat=Fit4238@output$matrices$s4238.S,Mmat=Fit4238@output$matrices$s4238.M)

Error in standardizeRAM(Fit4238, Amat = Fit4238@output$matrices$s4238.A, :

I need either mxRAMObjective or the names of the A and S matrices.

I've also tried with quotes around the matrix names.

I've also tried:

standardizeRAM(Fit4238,Amat=Fit4238@matrices$A@values,Smat=Fit4238@matrices$S@values,Mmat=Fit4238@matrices$M@values)

The correct syntax is:

standardizeRAM(Fit4238, Amat="A", Smat="S", Mmat="M")

Thanks. That does work. Aren't these names the standard names for these matrices? I would have tried these names but it seemed to simple and that something more was needed.

Yeah, I'd imagine most people will use matrices named "A", "S" and "M". I avoided the default because I didn't want to make unnecessary assumptions, and I hadn't come up with a good way to catch when someone had a matrix called "A" and it wasn't the A matrix (for instance, some people use words like "asym" or "arrows"). The function does automatically grab the names when you use the RAMObjective, but not with FIML.