Closed kingaa closed 3 years ago
It appears that the problem is to do with the fact that you sometimes have I < I_1
, in contradiction to your assumption that I_1 ~ Binomial(I,rho_I)
. This is evident in the error message, which prints the values of the state variables and the data (and also the parameters). To diagnose this, I ran your codes and noticed the messages coming from the dmeas
snippet. I modified that snippet as follows. This allowed me to see that the error was arising because I < I_1
.
dmeas <- Csnippet("
lik = dbinom(H_1,H + E + C2,rho_H,1) +
dbinom(I_1,I,rho_I,1);
lik = (give_log) ? lik : exp(lik);
if (!R_FINITE(lik)) Rprintf(\"dmeas: %lg %lg %lg %lg %lg %lg %lg\\n\",rho_H,rho_I,lik,H_1,I_1,H+E+C2,I);
")
However, there is nothing wrong with having a log likelihood of -Inf
(likelihood = 0) in your model. Therefore, this is a bug in bsmc2
. I have just committed a bug fix: it appears in version 3.4.2.0. Can you install it from source and have a look?
Thanks for your quick reply. It works now.
I am facing the same issue but with a log likelihood of Nan (likelihood=-Inf) in the model. This error appears in both bmsc2 and pmcmc. Is it not another bug? It supposes to reject such moves I think.
Recently, some colleagues (from an economic background) working on vineyard dieback came to me with the goal of extracting signals from data they have. Looking at their model, I thought POMP would be suitable as opposed to STAN (they planned to use). Because I have never used POMP myself, I tried to play with it myself. However, when I tried to use a Bayesian sequential monte carlo method on simulated data, I get the error
in ‘bsmc2’: ‘dmeasure’ with log=TRUE returns illegal value
. Part of the error message shows, I believe that the estimate of the likelihood at the initial guess is -Inf. After a long investigation, I still could not figure out what I was doing wrong.Simulate data:
Bayesian sequential Monte Carlo:
Error messages:
Diagnostics: