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() code with get_parameter() + Gamma() or LogNormal() #2

Closed
avallecam opened this issue Feb 13, 2024 · 3 comments
Closed
Labels
epinow2-cran Prep for EpiNow2 CRAN release

Comments

@avallecam
Copy link
Member

avallecam commented Feb 13, 2024

replace

serial_interval_covid <-
dist_spec(
mean = covid_serialint$summary_stats$mean,
sd = covid_serialint$summary_stats$sd,
max = covid_serialint_discrete_max,
distribution = "lognormal"
)
serial_interval_covid

from

# update: EpiNow2 1.4.9 ---------------------------------------------------

si_x <- seq(1L, to = covid_serialint_discrete_max, by = 1L)

serial_interval_covid_update <- 
  EpiNow2::dist_spec(pmf = covid_serialint_discrete$prob_dist$d(si_x))

serial_interval_covid_update
#> - nonparametric distribution
#>   PMF: [0.0073 0.1 0.2 0.19 0.15 0.11 0.075 0.051 0.034 0.023 0.016 0.011 0.0076 0.0053 0.0037 0.0027 0.0019 0.0014 0.001 0.00074 0.00055 0.00041 0.00031]

key learning goals

  • a simple way to plug in epiparameter is using the pmf
  • we can also use functions like LogNormal() or Gamma() but these require more (unnecessary) parameters
  • we need max parameter to plug in LogNormal() output to epinow()
  • the max parameter can come from a discretized continuous function as an epidist object
@avallecam
Copy link
Member Author

avallecam commented Feb 13, 2024

change my mind. the simpler input is still using the explicit distribution parameters

# new branch: is this a simpler and valid alternative? --------------------------------

covid_serialint_parameters <- epiparameter::get_parameters(covid_serialint)

covid_serialint_parameters
#>   meanlog     sdlog 
#> 1.3862617 0.5679803

serial_interval_covid_branch_lognormalmax <- 
  EpiNow2::LogNormal(
    meanlog = covid_serialint_parameters["meanlog"],
    sdlog = covid_serialint_parameters["sdlog"],
    max = covid_serialint_discrete_max)

serial_interval_covid_branch_lognormalmax
#> - lognormal distribution (max: 23):
#>   meanlog:
#>     1.4
#>   sdlog:
#>     0.57

updated

key learning goals

  • LogNormal() or Gamma() can be used for fixed and uncertain distributions
  • LogNormal() or Gamma() require lesser steps than pmf
  • LogNormal() or Gamma() must have the max parameter to plug in their output to epinow()
  • the max parameter can come from a discretized continuous function as an epidist object

comparison of steps

epidist

  • get_parameters()
  • discrete
    • max

compared to

epidist

  • discrete
  • max
  • seq
  • density
  • pmf

@avallecam avallecam changed the title replace dist_spec() code replace dist_spec() code with get_parameter() + Gamma or LogNormal Feb 13, 2024
@avallecam
Copy link
Member Author

this update depends on the merging of epiforecasts/EpiNow2#504

@avallecam avallecam changed the title replace dist_spec() code with get_parameter() + Gamma or LogNormal replace dist_spec() code with get_parameter() + Gamma() or LogNormal() Feb 13, 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
Status: Done
Development

No branches or pull requests

1 participant