You are here

Make running a CI for a fixed parameter is not cause error

The current behavior when a CI request is mxRun for a fixed parameter is to stop and return an error.

The desirable behavior is to insert the estimate into the lower and upper bound and continue.

Reporter: 
Created: 
Sun, 08/03/2014 - 18:46
Updated: 
Thu, 08/07/2014 - 12:43

Comments

The proposed check seems to require mind-reading. How do we know what the user intended? If it was a simple misspelling then it is appropriate to stop.

It's an unlikely typo to accidentally type the name of a fixed parameter, and it's not false that the CI of the fixed parameter is the estimate.

Emitting a warning would be plenty of "punishment".

The (very common) use case is the user generates all the labels from, say, an algebra, and currently has to filter them for being fixed (which might involve looking up free variables in other matrices in the case of an algebra).

The behavior to catch the typo case (and given the potential loss of days of run-time, I'd only issue a warning here is)

fixedParams  = omxGetParameters(model, free = FALSE)
freeParams   = omxGetParameters(model, free = TRUE)
 
if(myParam %in% freeParams{
  # run CI
}else{
   if(myParam %in% fixedParams){
       # put estimate in lower and upper bounds
   } else {
       warning("You asked for a CI on ", omxQuotes(myParam), "but this is not in the model")
   } 
}

Can you provide a complete example of a script that you think should work?

Thanks.

A warning for CI's of fixed matrix elements is fine IMO - even just marking them with an asterisk like we do for estimates on bounds would be ok by me. Note that no CPU time is needed - just skip estimation altogether.

Here's an example based on the ?mxCI one.

# generate data
covariance <- matrix(c(1.0, 0.5, 0.5, 1.0), 
    nrow=2, 
    dimnames=list(c("a", "b"), c("a", "b")))
data <- mxData(covariance, "cov", numObs=100)
 
# create an expected covariance matrix
expect <- mxMatrix("Symm", 2, 2,
    free=c(TRUE,TRUE,FALSE),
    values=c(1, .5, 1),
    labels=c("var1", "cov12", "var2"),
    name="expectedCov")
 
# request 95 percent confidence intervals   
ci <- mxCI(c("var1", "cov12", "var2"))
 
# specify the model
model <- mxModel(model="Confidence Interval Example",
    data, expect, ci,
    mxMLObjective("expectedCov", dimnames=c("a", "b")))
 
# run the model 
results <- mxRun(model, intervals=TRUE)
 
# view confidence intervals
print(summary(results)$CI)
 
# view all results
summary(results)

OK, we can make that work.

It is easier if we issue a message than to report the CI with lower and upper bounds equal.

See SVN 3729

Great, it now runs without error.

The behavior now is just to omit the CI if it is a fixed parameter. From a user perspective I think this is potentially puzzling. "I asked for a CI but didn't get it in the output, how come?" I'd rather see the CI's in the output, but with the estimates as upper & lower bounds and something to denote that the mxMatrix() element is fixed. This is a closer parallel to what happens to a mxAlgebra() element, which may or may not depend on any of the free parameters. Either way, the CI appears in the output.

Hm, that wasn't as hard as I expected. SVN 3733