lbound reset issues with omxSetParameters

3 replies [Last post]
wuhao_osu's picture
Offline
Joined: 09/07/2010

There seems to be two issues in using omxSetParameters to reset bounds. Please see below.

rm(list=ls());
require(OpenMx)

A<-mxMatrix(type="Full",nrow=1,ncol=1,free=T,values=.8,label="a",lbound=0,name="A");
model<-mxModel("model",A,mxAlgebra(A^2,name="A2"),mxAlgebraObjective("A2"))

###Now I would like to remove the lower bound

model0<-omxSetParameters(model,"a",lbound=NA)

### This gives an error: " 'lbound' argument must either be NA or a numeric vector. "
### But I was using NA exactly.

model0<-omxSetParameters(model,"a",lbound=NaN)
model0@matrices$A
### This time the reset is successful, though the previous error message suggests using NA.

mxRun(model0)
### The minimization is not successful. You can check the estimate.
### There is a warning saying: "In model 'model' NPSOL returned a non-zero status code 9. An input parameter ### was invalid "

A question: If I simply use -Inf instead of NaN, the reset is also successful, but the state of the model is different from one where the lbound is not set. Would there be numerical issues?

Thanks.

Hao

tbates's picture
Online
Joined: 07/31/2009
nice catch

Nice catch! I've never needed to (un)set a bound, only ever to set it, so hadn't seen this. Well done!

And Mike: It's nasty that (is.logical(NA) ==TRUE)... I assumed that is was a native numeric value of not defined, so interesting that it can be coerced to either.

Anyhow, good that the workaround is easy.

Another would be direct manipulation

model@matrices$A@lbound=matrix(NA)

mspiegel's picture
Offline
Joined: 07/31/2009
Whoops. That's a bug. You

Whoops. That's a bug. You can use model0 <- omxSetParameters(model,"a",lbound=as.numeric(NA)) as a workaround for now. NA values are logicals by default and the OpenMx implementation needs to convert them whenever we are performing typechecking.

wuhao_osu's picture
Offline
Joined: 09/07/2010
Thanks, it runs correctly for

Thanks, it runs correctly for my model now.