New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removing a known number of individuals from a specific compartment? #79
Comments
@gxvxn: apologies for being so very slow to reply. You may have resolved this issue already, or moved on entirely, but your main question, about how to remove a known number of individuals from a stochastic compartment, is an interesting one. In a certain sense, there is no inference problem here: the model is doing what it is supposed to do and negative numbers of infectives is one of the things it is asked to handle. The question really is a modeling question: what kind of model is appropriate in this situation? In this context, recall that a model is nothing other than a probability distribution, the hypothetical probability distribution of the data. In your case, this distribution is conditional on the number of removals. You could try to work out the proper form of the simulator conditional on these removals. That would appear to be difficult (at least to me, at this moment early on a Sunday morning) and unlikely to scale well. Are there other approaches you might consider? What about treating the removals as data? In the POMP context, you would have to allow for some (possibly trivial) measurement error on the removals. You would also have to model the removal process itself, which might be annoying and might or might not yet be worthwhile. If your limited goal is to estimate and maximize likelihoods using If the model is a good one, in the sense that it is capable of accounting for the data in a way that is compatible with the known removals, then you should, in principle have no problem. What I mean by this is that simulations of the model at the MLE, for example, will rarely if ever have fewer infectives than removals. Of course, it is also possible that, even at the MLE, a fair fraction of the simulations run afoul of this constraint. What are you to make of the simulations then, i.e., simulations that routinely produce |
Hi Dr. King, Thanks for your reply. I like your suggestion of treating the removals as data, and I think I can see how that would be worked in. I have moved on from this issue, although I may still have occasion to revisit this. The interim work-around I used (which seems to suit my purposes enough) was to treat removals as a rate, and from simulations at the MLE, double check that the median estimates using that rate fell reasonably close to the number removed (and they do). It's a little round-about, and it might be sacrificing a bit of information that could otherwise help inform parameter estimation, but there's additional ambiguity with these data beyond what's described above, so I think this is a reasonable approach. Thank you for your help! |
Sounds like a sensible compromise. Closing this issue now, but feel free to reopen if necessary. |
*edited: Found the answer to secondary issue of assigning start values for mif2 in 'pomp2'.
I have a 4-compartment model for a wildlife disease. All individuals are born susceptible (S), can become infected and infectious (I), then recover but remain test-positive (R1), and can eventually serorevert with retained immunity (R2). This subpopulation which I'm modeling had some individuals that were tested and killed. I've simplified the problem somewhat here, but this is the context for the question.
I'm treating births as known each year, and it would be convenient if I could treat these removals from
I
similarly. The issue is that the population is relatively small, and the number of removals can be high enough to depleteI
, leading to negative or NAN values, which makes the MLE search impossible.I'm using a discrete time model and trying to fit both a disease trend and the population trend simultaneously. I'm also modeling seroprevalence (rather than something like case number) which is the proportion of individuals in
I
andR1
from the total population. My data for this are the number of positive tests,pos
, from the total number of tests,tot
.I'm working in pomp2.
My model:
I can simulate from this model, and some runs (as expected) deplete
I
and 'break'.These parameter values at least seem to be getting us in the ballpark. I've omitted some other data,
and expect a bit of noise, so to me this doesn't look too awful.
pfilter should fail:
Ultimately I want to be able to conduct the MLE search with
mif2
, so I've attached code below for that in case it is useful. One idea I tried is to replace the transition equations inrproc
to include anifelse
statement... basically ifI
gets depleted, assign it a zero value:Surprisingly, this doesn't throw errors, but from the simulations it's clear that it's not doing what I intended... actually I can't tell what, if anything, it is doing.
Any suggestions? What options do I have?
This has been fixed, leaving in case it's useful for others:
This is an aside, so maybe it belongs in a separate question, but I've been getting this error in pomp2 which didn't occur in the previous pomp version I had installed. I'm not sure what is going on.
Possibly myIf I don't run this line:foreach
code is incorrect.don't run this! this assigns a point estimatecoef(m2) <- paramvals
then the following call to
stew
returns an error message. I think you should be able to replicate the error here, even though once it's fixed stew should fail and spit out the parameters whenI
gets depleted. (I have this same issue for models of other populations that don't include removals.)Here's the error:
Error in { : task 1 failed - "in 'mif2': the following parameter(s), given random walks in 'rw.sd', are not present in 'start': 'beta','bp','mu1','mu2','mu3','sigma','gamma','theta','iota','S_0','I_0','R1_0','R2_0'."
Here's the
stew
code block:Since all of those 'start' parameters are included inparamvals
, which is included in.export=
, I thought this should run. Assigningparamvals
tocoef(m2)
gets rid of the error. What's happening?The text was updated successfully, but these errors were encountered: