I also used traj_func()
to do a global search on likelihood, it returns NA most of the time and few valid numbers on discrete parameter combinations.
Can you please tell me what might go wrong? Thank you so much!!
","upvoteCount":1,"answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"I notice that you round J
in ili_nll_objfun
, but not in traj_func
. Notice that dbinom
insists (correctly) on size
being an integer:
dbinom(50,size=c(100,100.1),prob=0.5)\n[1] 0.07958924 NaN\nWarning message:\nIn dbinom(50, size = c(100, 100.1), prob = 0.5) : NaNs produced\n
The usual rounding function in C is nearbyint
. Cf. the following:
### measure model ###\ninc_dmeas <- Csnippet(\"\n lik = dbinom(ili, nearbyint(J), rho, give_log);\n\")\n\n## build traj_func using simulated data ##\ndata.frame(\n daynum = seq(from=3653,to=3653 + 3652)\n) |>\n mutate(\n ili = round(\n rbinom(\n n = length(daynum),\n size = 120,\n prob = 0.5 + rnorm(n=length(daynum),sd = 0.01)\n ) +\n 2 * sin(2*pi/365*daynum)\n )\n ) |>\n traj_objfun(\n times = \"daynum\",\n t0 = 1,\n rinit = sirs_init,\n skeleton = pomp::map(sirs_annual_beta_skeleton, delta.t = 1),\n dmeasure = inc_dmeas,\n accumvars = \"J\",\n params = c(\n beta = 0.2,seas = 0.02,\n rho = 0.01,mu_R = 4/150,\n mu_IR = 1/5,N = 1e7\n ),\n est = c(\"beta\",\"seas\",\"rho\",\"mu_R\"),\n paramnames = c(\"beta\",\"seas\",\"mu_IR\",\"mu_R\",\"N\",\"rho\"),\n statenames = c(\"S\",\"I\",\"R1\",\"R2\",\"R3\",\"R4\",\"J\")\n ) -> traj_func\n\ntraj_func(c(beta = 0.2,seas = 0.02,mu_R = 4/150,rho = 0.01))\n[1] 14292.71\n
I also notice that you have extraneous code in your example. Please reduce your examples to their essentials. Not only is this a courtesy to those you are asking for help, and to the readers of this discussion, but it may help you find the error yourself!
","upvoteCount":1,"url":"https://github.com/kingaa/pomp/discussions/190#discussioncomment-5469596"}}}-
I'm using I'm building a SIRS model. Below is my code in pomp:
I also used Can you please tell me what might go wrong? Thank you so much!! |
Beta Was this translation helpful? Give feedback.
-
I notice that you round
The usual rounding function in C is
I also notice that you have extraneous code in your example. Please reduce your examples to their essentials. Not only is this a courtesy to those you are asking for help, and to the readers of this discussion, but it may help you find the error yourself! |
Beta Was this translation helpful? Give feedback.
I notice that you round
J
inili_nll_objfun
, but not intraj_func
. Notice thatdbinom
insists (correctly) onsize
being an integer:The usual rounding function in C is
nearbyint
. Cf. the following: