Skip to content
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 chapter 24 (epinow function) due to missing values #108

Open
mcewenkhundi opened this issue May 28, 2022 · 1 comment
Open

Error in chapter 24 (epinow function) due to missing values #108

mcewenkhundi opened this issue May 28, 2022 · 1 comment

Comments

@mcewenkhundi
Copy link

mcewenkhundi commented May 28, 2022

Dear Authors,

In chapter 24, the epinow function gets an error due to missing values in the date_onset variable. I have solved this by filtering out the missing values by adding the commented line in the code below. The original data is from the linelist_cleaned.rds

Is this the correct approach or should I use the dplyr::complete function that has been used in the section https://epirhandbook.com/en/epidemic-modeling.html#epiestim to solve a similar problem?

I have pasted the error message at the bottom for your reference.

get incidence from onset dates

cases <- linelist %>%
#filter(!is.na(date_onset)) %>%
group_by(date = date_onset) %>%
summarise(confirm = n())

run epinow to calculate Rt

epinow_res <- epinow(
reported_cases = cases,
generation_time = generation_time,
delays = delay_opts(incubation_period),
return_output = TRUE,
verbose = TRUE,
horizon = 21,
stan = stan_opts(samples = 750, chains = 4)
)

Logging threshold set at INFO for the EpiNow2 logger
Writing EpiNow2 logs to the console and: C:\Users\mkhundi\AppData\Local\Temp\Rtmps1xhoN/regional-epinow/2015-04-30.log
Logging threshold set at INFO for the EpiNow2.epinow logger
Writing EpiNow2.epinow logs to the console and: C:\Users\mkhundi\AppData\Local\Temp\Rtmps1xhoN/epinow/2015-04-30.log
Error in seq.int(0, to0 - from, by) : 'to' must be a finite number

@Dr-A-Soni
Copy link

I tried your above code but the resulting graph shows a little bit of variation from the one in the book since it is missing 10 days (2014-04-07: 2014-4-16). As the estimates variable starts from 2014-04-07 in the book but following the above code, the estimates variable starts from 2014-04-17. Code does run after the adding (filter) command but it results in 10 days missing which is reflected in the graph.
If anyone can help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants