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

Detection of accumulation for forecasts doesn't work #934

Closed
sbfnk opened this issue Jan 28, 2025 · 0 comments · Fixed by #935
Closed

Detection of accumulation for forecasts doesn't work #934

sbfnk opened this issue Jan 28, 2025 · 0 comments · Fixed by #935
Assignees

Comments

@sbfnk
Copy link
Contributor

sbfnk commented Jan 28, 2025

I can see where the issue is and will try to issue a fix

library("EpiNow2")
#> 
#> Attaching package: 'EpiNow2'
#> The following object is masked from 'package:stats':
#> 
#>     Gamma
library("data.table")

reported_cases <- EpiNow2::example_confirmed
reported_cases_weekly <- data.table::copy(reported_cases)
reported_cases_weekly[, confirm := frollsum(confirm, 7)]
reported_cases_weekly <- fill_missing(
  reported_cases_weekly[seq(7, nrow(reported_cases_weekly), 7)],
  missing_dates = "accumulate"
)
#> Warning: ! Initial data point not marked as accumulated but some others are.
#> ℹ This means that the first data point will not be included in the likelihood.
#> ℹ To change this behaviour, set `initial_accumulate` (including setting it to 1
#>   if the first data point is to be taken as is, i.e. as the first daily data
#>   point).

est <- epinow(
  reported_cases_weekly,
  generation_time = generation_time_opts(example_generation_time),
  verbose = FALSE
)
#> Logging threshold set at INFO for the name logger
#> Writing EpiNow2 logs to the console and:
#> '/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T//RtmpuWHsSK/regional-epinow/2020-06-26.log'.
#> Logging threshold set at INFO for the name logger
#> Writing EpiNow2.epinow logs to the console and:
#> '/var/folders/n9/h_419gjj2mg3d208nplgvbg40000gp/T//RtmpuWHsSK/epinow/2020-06-26.log'.
#> WARN [2025-01-28 14:08:35] epinow: The `filter_leading_zeros` argument of `estimate_infections()` is deprecated as of EpiNow2 1.7.0. - 
#> WARN [2025-01-28 14:08:35] epinow: The `zero_threshold` argument of `estimate_infections()` is deprecated as of EpiNow2 1.7.0. -
#> ℹ As of version 1.5.0 missing dates or dates with `NA` cases are treated as
#>   missing. This is in contrast to previous versions where these were
#>   interpreted as dates with zero cases.
#> ℹ In order to treat missing or `NA` cases as zeroes, see solutions in
#>   <https://github.com/epiforecasts/EpiNow2/issues/767#issuecomment-2348805272>
#> ℹ If the data is reported at non-daily intervals (for example weekly), consider
#>   using `obs_opts(na="accumulate")`.
#> ℹ For more information on these options, see `?obs_opts`.
#> This message is displayed once every 8 hours.
#> WARN [2025-01-28 14:12:04] epinow: There were 22 divergent transitions after warmup. See
#> https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
#> to find out why this is a problem and how to eliminate them. - 
#> WARN [2025-01-28 14:12:04] epinow: Examine the pairs() plot to diagnose sampling problems
#>  - 
#> WARN [2025-01-28 14:12:05] epinow: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
#> Running the chains for more iterations may help. See
#> https://mc-stan.org/misc/warnings.html#bulk-ess -

est$estimates$summarised[variable == "reported_cases", list(date, type)]
#>           date                           type
#>         <Date>                         <char>
#>  1: 2020-03-06                       estimate
#>  2: 2020-03-13                       estimate
#>  3: 2020-03-20                       estimate
#>  4: 2020-03-27                       estimate
#>  5: 2020-04-03                       estimate
#>  6: 2020-04-10                       estimate
#>  7: 2020-04-17                       estimate
#>  8: 2020-04-24                       estimate
#>  9: 2020-05-01                       estimate
#> 10: 2020-05-08                       estimate
#> 11: 2020-05-15                       estimate
#> 12: 2020-05-22                       estimate
#> 13: 2020-05-29                       estimate
#> 14: 2020-06-05                       estimate
#> 15: 2020-06-12                       estimate
#> 16: 2020-06-19 estimate based on partial data
#> 17: 2020-06-26 estimate based on partial data
#> 18: 2020-06-27                       forecast
#> 19: 2020-06-28                       forecast
#> 20: 2020-06-29                       forecast
#> 21: 2020-06-30                       forecast
#> 22: 2020-07-01                       forecast
#> 23: 2020-07-02                       forecast
#> 24: 2020-07-03                       forecast
#>           date                           type

Created on 2025-01-28 with reprex v2.1.1

@sbfnk sbfnk self-assigned this Jan 28, 2025
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

Successfully merging a pull request may close this issue.

1 participant