appliedepi / epiRhandbook_eng

The repository for the English version of the Epidemiologist R Handbook
Other
97 stars 56 forks source link

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

Open mcewenkhundi opened 2 years ago

mcewenkhundi commented 2 years ago

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 commented 10 months ago

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