You are here

Side effect of lbounding? F matrix associated with RAM expectation function contains dimnames and expectation has dimnames

The following code runs a RAM model, then lbounds a path at zero.

Running that model dies with an error about the F matrix contains dimnames and the expectation function has dimnames.

Seems a not easy to diagnose what to do, but also wrong to fail in this case? (the bound is legal).

data(myFADataRaw, package="OpenMx")
manifests = names(myFADataRaw)
latents   = c("G")
m1 <- mxModel("m1", type="RAM",
    manifestVars = manifests, latentVars   = latents,
    mxPath(from = latents, to = manifests),
    mxPath(from = manifests, arrows = 2), # manifest residuals 
    mxPath(from = latents, arrows = 2, free = F, values = 1), # latent fixed@1
    mxPath(from = c("x1", "x2"), to = "x3", arrows = 1), # manifest causes
    mxPath(from = "one", to = manifests, arrows = 1), # manifest means
    mxData(myFADataRaw, type = "raw")
)
m1 = mxRun(m1)
summary(m1)$parameters[3,2:6] # 0.803
m1@matrices$A@lbound["x1", "G"] = 0 # lbound G->x1 @ 0 
m1 = mxRun(m1) 
# Running m1
# Error: The F matrix associated with the RAM expectation function in model 'm1' contains dimnames and the expectation function has specified dimnames
Reporter: 
Created: 
Tue, 10/28/2014 - 11:13
Updated: 
Fri, 10/31/2014 - 00:58

Comments

This has nothing to do with the lbound. It's just from re-running a model. The issue is that the backend thinks 'dims' are only manifest variables, but the RAM frontend thinks 'dims' are latent and manifest variables. When the model is run, I update the expectation 'dims' with the backend information so the saturated model helper can use those to make the reference models. When you run the model again, RAM wants latent and manifest 'dims', not the manifest-only backend 'dims'.

I agree that this should be fixed. I'm not completely sure of the best solution. In the meantime, you have options. First, you could store the model results separately from the model spec.

m1r <- mxRun(m1)
m1@matrices$A@lbound["x1", "G"] = 0
m1r = mxRun(m1) #works fine

Second, you could clear the 'dims' before re-running.

m1 <- mxRun(m1)
m1@matrices$A@lbound["x1", "G"] = 0
m1@expectation@dims <- as.character(NA)
m1 = mxRun(m1) #works fine

Mike, do you think you could store the backend expectation dims in a different slot, instead of clobbering the user-provided expectation dimnames? Say, private slot .backendDims? This error is going to be really annoying to a lot of people, and will kill mxTryHard()'s usability with some models.

Joshua is working on a patch to add .runDims, precisely that suggestion. We definitely want to fix this error ASAP. I'm stumped at how make test didn't catch it.

Pls try SVN 3951

Thanks, Joshua, for the fix!