Referencing Data in an Algebra for mxAlgebraObjective
Posted on

Forums
I'm trying to spec out a least-squares based optimizer using the mxAlgebraObjective, but I've been unable to include data in an algebra. Is that possible/feasible, or do I need to move to mxRObjective?
An mxAlgebraObjective only
An mxAlgebraObjective only runs on the matrices and algebras included in the model directly, and doesn't use data from the mxData command. If you're trying to calculate an algebra based on a covariance matrix, just include the covariance matrix in the model as an mxMatrix. You can use something like:
myData <- matrix(....)
model <- mxModel(
mxMatrix(type="Full", nrow=nrow(myData), ncol = ncol(myData), free=FALSE, values=myData, name="theData")
)
and then just use "theData" in your objective algebra.
Is that what you're looking for?
Log in or register to post comments
In reply to An mxAlgebraObjective only by tbrick
Yeah Steve has some models
Yeah Steve has some models where he would like to use data inside a mxAlgebra statement. His current workaround is to include the data in a mxMatrix object. We talked about allowing data access from an algebra in the post-1.0 release.
Log in or register to post comments
I guess I would recommend
I guess I would recommend using mxRObjective since that is what it is designed for: Building new objective function classes without having to touch any C coding.
The disadvantage is that it may take more time to code and certainly will estimate more slowly.
The advantage is that it may speed the translation of the objective function into a C function(s) in the backend.
My advice is predicated on the idea that WLS in the backend is your target.
Log in or register to post comments