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

Fix plot.estimate_secondary() for forecast_secondary() output #836

Merged
merged 1 commit into from
Oct 23, 2024

Conversation

jamesmbaazam
Copy link
Contributor

@jamesmbaazam jamesmbaazam commented Oct 23, 2024

Description

This PR closes #702 by reverting a change that removed NA secondary rows, thereby dropping the data needed to plot forecast "secondary" outcomes.

Initial submission checklist

  • My PR is based on a package issue and I have explicitly linked it.
  • I have tested my changes locally (using devtools::test() and devtools::check()).
  • I have added or updated unit tests where necessary.
  • I have updated the documentation if required and rebuilt docs if yes (using devtools::document()).
  • I have followed the established coding standards (and checked using lintr::lint_package()).
  • I have added a news item linked to this PR.

After the initial Pull Request

  • I have reviewed Checks for this PR and addressed any issues as far as I am able.

@jamesmbaazam
Copy link
Contributor Author

New plot with code in linked issue

devtools::load_all()
library(cfr)
library(tidyverse)

# data --------------------------------------------------------------------

reported_cases_deaths <- cfr::ebola1976 %>% 
  dplyr::rename(primary = cases, secondary = deaths)

# Estimate from day 1 to day 35 of this data
cases_to_estimate <- reported_cases_deaths %>%
  slice(1:35)

# Forecast from day 36 to day 73
cases_to_forecast <- reported_cases_deaths %>%
  dplyr::slice(36:73) %>% 
  dplyr::mutate(value = primary)


# EpiNow2 -----------------------------------------------------------------

# delay
delay_uncertain <- EpiNow2::Gamma(
  mean = EpiNow2::Normal(mean = 14, sd = 0.5),
  sd = EpiNow2::Normal(mean = 5, sd = 0.5),
  max = 30
)

# estimate secondary cases
secondary_uncertain <- EpiNow2::estimate_secondary(
  data = cases_to_estimate,
  delays = EpiNow2::delay_opts(delay_uncertain)
)

# forecast secondary cases
forecast_uncertain <- EpiNow2::forecast_secondary(
  estimate = secondary_uncertain,
  primary = cases_to_forecast
)

plot(forecast_uncertain)

Rplot

Copy link
Contributor

@seabbs seabbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. LGTM

@seabbs seabbs added this pull request to the merge queue Oct 23, 2024
Merged via the queue into main with commit c122528 Oct 23, 2024
9 checks passed
@seabbs seabbs deleted the fix-plot.est_sec branch October 23, 2024 18:49
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 this pull request may close these issues.

error in plot.estimate_secondary() to plot the output from forecast_secondary()
2 participants