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

Error in rmultinom(length(which(Onset == t)), size = 1, prob = SI.Distr[t - : no positive probabilities #4

Closed
caijun opened this Issue Nov 17, 2016 · 2 comments

Comments

Projects
None yet
2 participants
@caijun
Copy link

caijun commented Nov 17, 2016

Hi @annecori When I used the Wallinga and Teunis method function WT to estimate the case reproduction number, it threw following error.

Error in rmultinom(length(which(Onset == t)), size = 1, prob = SI.Distr[t -  : 
  no positive probabilities

Here is my reproducible code

rm(list = ls())
load(url("http://tonytsai.name/41_Henan_stu_dec.rda"))

# plot epidemic curve
par(cex.main = 1.5, mfrow = c(1, 1), mar = c(2, 4, 2, 2.5))
plot(stu.dec$cases, type = "l")

# case reproduction number estimaion for pandemic
# using the Wallinga and Teunis method
t.start <- 130
Rc <- WT(stu.dec$cases, T.Start = t.start:359, T.End = (t.start + 6):365, method = "ParametricSI", 
         Mean.SI = 2.6, Std.SI = 1.3, plot = TRUE, nSim = 100)

I encountered the same error when the value of t.start is small; however, after I increased t.start to 130, it still threw the error. From the plot of epidemic curve, after the 130th day, there were enough cases. Could you please help me look at this problem? Thank you very much.

image

Besides, I have implemented a method to automatically determine the minimum value of t.start that the EstimateR and WT functions can successfully complete the estimation of reproduction number without throwing a warning or an error. I think this would be a feature necessary to EpiEstim package.

@annecori

This comment has been minimized.

Copy link
Owner

annecori commented Nov 17, 2016

Hi @caijun
Thanks for reporting this bug. The issue was due to the very late isolated case in your dataset that appears at time 312; of course with the SI distribution you are using there is no way this case has been infected by one of the previous cases; I hadn't accounted for the possibility that such a long gap with no cases could happen. Should be sorted in the version I've just pushed - please as before just copy the WT function code from github - I need to work on the package soon!
I hope that helps
Thanks
Anne

caijun added a commit to caijun/EpiEstim that referenced this issue Nov 17, 2016

@caijun

This comment has been minimized.

Copy link
Author

caijun commented Nov 17, 2016

It works, thank you very much @annecori

@caijun caijun closed this Nov 17, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment