mxRename of fitted model objects leaves mxConstraint() objects unrenamed

neale's picture
Project:OpenMx
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:closed
Description

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

Comments

tbates's picture

#1

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)

neale's picture

#2

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.

mhunter's picture

#3

Status:active» fixed

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)

mhunter's picture

#4

Status:fixed» closed