You are here

omx[Get/Set]Parameters with anonymous free parameters

3 posts / 0 new
Last post
mspiegel's picture
Offline
Joined: 07/31/2009 - 15:24
omx[Get/Set]Parameters with anonymous free parameters

Since we were cleaning up the saving and loading of models (see https://openmx.ssri.psu.edu/thread/1385), on a related matter I decided to support anonymous free parameters in the utility functions omxGetParameters() and omxSetParameters(). Anonymous free parameters (free parameters that have a label of 'NA') are now identified by the string "modelname.matrixname[row,col]". This notation will be available as input to the function omxSetParameters(), which currently rejects anonymous free parameters. The following demo will work in OpenMx 1.3.

require(OpenMx)

data(demoOneFactor)
manifestVars <- names(demoOneFactor)

factorModel <- mxModel("One Factor",
    mxMatrix(type="Full", nrow=5, ncol=1, values=0.2, free=TRUE, name="A",
        labels=letters[1:5]),
    mxMatrix(type="Symm", nrow=1, ncol=1, values=1, free=FALSE, name="L"),

    # the "U" matrix has 5 anonymous free parameters
    mxMatrix(type="Diag", nrow=5, ncol=5, values=1, free=TRUE, name="U"),

    mxAlgebra(expression=A %*% L %*% t(A) + U, name="R"),
    mxMLObjective(covariance="R", dimnames=manifestVars),
    mxData(observed=cov(demoOneFactor), type="cov", numObs=500)
)

params <- omxGetParameters(factorModel)
newFactorModel <- omxSetParameters(factorModel, names(params), values = 1:10)
newParams <- omxGetParameters(newFactorModel)

(If the example used symmetric matrices, both the cell and the transpose of the cell would have been populated)

tbates's picture
Offline
Joined: 07/31/2009 - 14:25
Very useful upgrade!

That will be handy Michael: thanks!

tbates's picture
Offline
Joined: 07/31/2009 - 14:25
Is there a timeline for this in 1.3 or latest

User requesting this functionality (which worked for me on SVN version), but they can't then run my script.

Even on: install.packages('OpenMx', repos='http://openmx.psyc.virginia.edu/testing/');

t