You are here

mxRename of fitted model objects leaves mxConstraint() objects unrenamed

require(OpenMx)
aMat <- mxMatrix("Full", 1,1, name="aMat")
aCon <- mxConstraint(diag2vec(aMat)==0,name="aCon")
 
mx101a13  <- mxModel( "mx101a13", aMat, aCon)
summary(mx101a13run <- mxRun(mx101a13))
mx101a15  <- mxRename(mx101a13run, newname="mx101a15")
summary(mx101a15)

Yields:
> summary(mx101a15)
Error: The following error occurred while evaluating the expression 'diag2vec(mx101a13.aMat)' in model 'mx101a15' : object 'mx101a13.aMat' not found

Reporter: 
Created: 
Fri, 10/25/2013 - 17:07
Updated: 
Wed, 05/07/2014 - 18:44

Comments

Looks like summary() needs to append a helping-hint to that error: "If you have renamed the model since running it, you will need to run it again before summary will work... mname <- mxRun(mname) "

require(OpenMx)
aMat     <- mxMatrix("Full", 1,1, name="aMat")
aCon     <- mxConstraint(diag2vec(aMat) == 0, name = "aCon")
mx101a13 <- mxModel( "mx101a13", aMat, aCon)
mx101a13 <- mxRun(mx101a13)
mx101a15 <- mxRename(mx101a13, newname = "mx101a15")
mx101a15 <- mxRun(mx101a15)
summary(mx101a15)

That is a workaround. For a job that took a week to run, it might be a bit of a big ask. Of course, the user could get the same info by summary() before rename. Not sure if mxCompare() would also be compromised by this issue.

I fixed this: r3431. There were two problems. First, mxRename wasn't renaming all the relevant slots in mxConstraints. Second, because summary uses the runstate information we now also rename constraints in the runstate (when it exists).

require(OpenMx)
 
aMat <- mxMatrix("Full", 1,1, name="aMat")
aCon <- mxConstraint(diag2vec(aMat)==0,name="aCon")
 
rTom  <- mxModel( "Tom", aMat, aCon)
summary(rTomRun <- mxRun(rTom))
rNeal  <- mxRename(rTomRun, newname="Neal")
summary(rNeal)