-
Couldn't load subscription status.
- Fork 23
Description
I'm setting up to run the MCEM algorithm (test data and algorithm are attached).
I run the following steps without problems:
brownianModel <-
nimbleModel(brownianModelCode1,
constants=list(N=N,J=J,NT=NT,
deltaT=deltaT,
tasks=tasks),
dimensions=list(p=c(N,NT,3L)),
inits=bminits,check=FALSE,
data=list(y=y),
buildDerivs = TRUE)
cBrownianModel <- compileNimble(brownianModel,showCompilerOutput=FALSE)
brownianMCEM <- buildMCEM(model=brownianModel,latentNodes="theta")
cBrownianMCEM <- compileNimble(brownianMCEM,project=brownianModel)
The I try to run the MCEM algorithm and it diverges, however, the error message is unhelpful and incorrect.
> cBrownianMCEM$findMLE(initM=1000)
## Error in cBrownianMCEM$findMLE(initM = 1000) :
## Non-finite log-likelihood occurred; the MCEM optimization cannot continue. Please check the state of the compiled model (accessible as 'name_of_model$CobjectInterface') and determine which parameter values are causing the invalid log-likelihood by calling 'calculate' with subsets of the model parameters (e.g., 'name_of_model$CobjectInterface$calculate('y[3]')' to see if node 'y[3]' is the cause of the problem). Note that if your model is maximizing over parameters whose bounds are not constant (i.e., depend on other parameters), this is one possible cause of such problems; in that case you might try running the MCEM without bounds, by setting 'forceNoConstraints = TRUE'.
My first issue, is that I don't know what name_of_model in the error message refers to. I have cBrownianMCEM, brownianMCEM, cBrownianModel and BrownianModel.
A little bit of poking around revealed that the the field is $.CobjectInterface while the error message has this field named without the ..
> cBrownianMCEM$CobjectInterface
Error in envRefInferField(x, what, getClass(class(x)), selfEnv) :
‘CobjectInterface’ is not a valid field or method name for reference class “MCEM_refClass”
> brownianMCEM$CobjectInterface
Error in envRefInferField(x, what, getClass(class(x)), selfEnv) :
‘CobjectInterface’ is not a valid field or method name for reference class “MCEM”
> brownianMCEM$.CobjectInterface
Derived CnimbleFunctionBase object (compiled nimbleFunction) for nimbleFunction with class MCEM
The $.CobjectInterface object does not have a $calculate() method.
> brownianMCEM$.CobjectInterface$calculate("mu_0")
Error in envRefInferField(x, what, getClass(class(x)), selfEnv) :
‘calculate’ is not a valid field or method name for reference class “MCEM_refClass”
Going back to the cBrownianModel object, I can access the parameters using, for example:
> cBrownianModel$sigma_0
[1] 0.1263482
> cBrownianModel$calculate("sigma_0")
[1] -0.0819634
But, I have no idea if this object reflects the state of the MCEM algorithm when it diverged.
In addition to fixing the error message, it would be useful to have an example of debugging a convergence problem.