Standardize a RAM Model
Posted on

Attachment | Size |
---|---|
standardizeRAM.R | 3.07 KB |
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.
Hi Ryne: This will be very
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
Log in or register to post comments
In reply to Hi Ryne: This will be very by tbates
You're right. I did that as a
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).
Log in or register to post comments
gone?
Log in or register to post comments
Drupal freaked out a bit.
Log in or register to post comments
Hi. What am I doing wrong?
> 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)
Log in or register to post comments
In reply to Hi. What am I doing wrong? by rabil
The correct syntax
standardizeRAM(Fit4238, Amat="A", Smat="S", Mmat="M")
Log in or register to post comments
In reply to The correct syntax by Ryne
Thanks. That does work.
Log in or register to post comments
In reply to Thanks. That does work. by rabil
Yeah, I'd imagine most people
Log in or register to post comments