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

replace dist_spec() with Gamma() in ebola challenge #6

Closed
avallecam opened this issue Feb 20, 2024 · 1 comment
Closed

replace dist_spec() with Gamma() in ebola challenge #6

avallecam opened this issue Feb 20, 2024 · 1 comment
Labels
epinow2-cran Prep for EpiNow2 CRAN release

Comments

@avallecam
Copy link
Member

avallecam commented Feb 20, 2024

After epiforecasts/EpiNow2#504

replace challenge in

```{r,message=FALSE,warning=FALSE,eval=TRUE}
# subset one distribution
ebola_serial <- epidist_db(
disease = "ebola",
epi_dist = "serial",
single_epidist = TRUE
)
# adapt epiparameter to epinow2
ebola_serial_discrete <- discretise(ebola_serial)
ebola_serial_discrete_max <- quantile(ebola_serial_discrete, p = 0.999)
serial_interval_ebola <-
dist_spec(
mean = ebola_serial$summary_stats$mean,
sd = ebola_serial$summary_stats$sd,
max = ebola_serial_discrete_max,
distribution = "gamma" # don't forget! it's a must!
)

library(epiparameter)
library(EpiNow2)
#> Warning: package 'EpiNow2' was built under R version 4.2.3

ebola_serial <- epidist_db(
  disease = "ebola",
  epi_dist = "serial",
  single_epidist = TRUE
)
#> Using WHO Ebola Response Team, Agua-Agum J, Ariyarajah A, Aylward B, Blake I,
#> Brennan R, Cori A, Donnelly C, Dorigatti I, Dye C, Eckmanns T, Ferguson
#> N, Formenty P, Fraser C, Garcia E, Garske T, Hinsley W, Holmes D,
#> Hugonnet S, Iyengar S, Jombart T, Krishnan R, Meijers S, Mills H,
#> Mohamed Y, Nedjati-Gilani G, Newton E, Nouvellet P, Pelletier L,
#> Perkins D, Riley S, Sagrado M, Schnitzler J, Schumacher D, Shah A, Van
#> Kerkhove M, Varsaneux O, Kannangarage N (2015). "West African Ebola
#> Epidemic after One Year — Slowing but Not Yet under Control." _The New
#> England Journal of Medicine_. doi:10.1056/NEJMc1414992
#> <https://doi.org/10.1056/NEJMc1414992>.. 
#> To retrieve the short citation use the 'get_citation' function

# adapt epiparameter to epinow2
ebola_serial_discrete <- discretise(ebola_serial)

ebola_serial_discrete_max <- quantile(ebola_serial_discrete, p = 0.999)

serial_interval_ebola <-
  dist_spec(
    mean = ebola_serial$summary_stats$mean,
    sd = ebola_serial$summary_stats$sd,
    max = ebola_serial_discrete_max,
    distribution = "gamma" # don't forget! it's a must!
  )
#> Warning: The meaning of the 'max' argument has changed compared to previous versions. It now indicates the maximum of a distribution rather than the length of the probability mass function (including 0) that it represented previously. To replicate previous behaviour reduce max by 1.
#> This warning is displayed once every 8 hours.

serial_interval_ebola
#> 
#>   Fixed distribution with PMF [0.0063 0.02 0.031 0.039 0.045 0.05 0.052 0.053 0.052 0.051 0.049 0.047 0.045 0.042 0.039 0.036 0.034 0.031 0.028 0.026 0.023 0.021 0.019 0.017 0.016 0.014 0.013 0.011 0.01 0.009 0.0081 0.0072 0.0064 0.0057 0.005 0.0045 0.004 0.0035 0.0031 0.0027 0.0024 0.0021 0.0019 0.0017 0.0015 0.0013 0.0011 0.00099 0.00087 0.00077 0.00067 0.00059 0.00052 0.00045 4e-04 0.00035 0.00031 0.00027 0.00023 2e-04 0.00018 0.00016 0.00014]

Created on 2024-02-26 with reprex v2.0.2

by

library(epiparameter)
library(EpiNow2)
#> 
#> Attaching package: 'EpiNow2'
#> The following object is masked from 'package:epiparameter':
#> 
#>     discretise
#> The following object is masked from 'package:stats':
#> 
#>     Gamma

ebola_serial <- epidist_db(
  disease = "ebola",
  epi_dist = "serial",
  single_epidist = TRUE
)
#> Using WHO Ebola Response Team, Agua-Agum J, Ariyarajah A, Aylward B, Blake I,
#> Brennan R, Cori A, Donnelly C, Dorigatti I, Dye C, Eckmanns T, Ferguson
#> N, Formenty P, Fraser C, Garcia E, Garske T, Hinsley W, Holmes D,
#> Hugonnet S, Iyengar S, Jombart T, Krishnan R, Meijers S, Mills H,
#> Mohamed Y, Nedjati-Gilani G, Newton E, Nouvellet P, Pelletier L,
#> Perkins D, Riley S, Sagrado M, Schnitzler J, Schumacher D, Shah A, Van
#> Kerkhove M, Varsaneux O, Kannangarage N (2015). "West African Ebola
#> Epidemic after One Year — Slowing but Not Yet under Control." _The New
#> England Journal of Medicine_. doi:10.1056/NEJMc1414992
#> <https://doi.org/10.1056/NEJMc1414992>.. 
#> To retrieve the short citation use the 'get_citation' function

# adapt epiparameter to epinow2
ebola_serial_discrete <- epiparameter::discretise(ebola_serial)

ebola_serial_discrete_max <- quantile(ebola_serial_discrete, p = 0.999)

serial_interval_ebola <-
  Gamma(
    mean = ebola_serial$summary_stats$mean,
    sd = ebola_serial$summary_stats$sd,
    max = ebola_serial_discrete_max
  )

serial_interval_ebola
#> - gamma distribution (max: 62):
#>   shape:
#>     2.2
#>   rate:
#>     0.15

Created on 2024-02-26 with reprex v2.1.0

UPDATE:

  • added reprex to this issue
@avallecam avallecam changed the title remove pmf() and use directly Gamma() in ebola challenge replace dist_spec() with Gamma() in ebola challenge Feb 26, 2024
@avallecam avallecam added the epinow2-cran Prep for EpiNow2 CRAN release label Mar 21, 2024
@avallecam
Copy link
Member Author

fixed in #80

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
epinow2-cran Prep for EpiNow2 CRAN release
Projects
None yet
Development

No branches or pull requests

1 participant