epiparameter icon indicating copy to clipboard operation
epiparameter copied to clipboard

Add how to use a conversion function to build a custom epidist class object

Open avallecam opened this issue 1 year ago • 5 comments

Conversion functions are great to convert the usually reported summary statistics to probability distribution parameters.

In a coming vignette about conversion functions, they can be shown in an example that solve the problem of how to build a custom epidist object with "gamma".

In other words, following this order:

  • first, show how to build a custom epidist object with "lnorm" probability distribution? (as used in the showcase)
  • then propose a new reasonable problem: "but now, how to build a custom epidist object with "gamma"? we can not use mean and sd as probability distribution parameters for gamma."
  • this problem should motivate the introduction of conversion functions to solve it.

i.e.:

  • first, get a new pair of summary statistics from the literature,
  • then, convert these summary statistics to probability distribution parameters,
  • finally, use epidist() to create an epidist class object.
library(epiparameter)
library(tidyverse)

eparams <- epiparam()

# problem: how to build a custom `epidist` object not with "lnorm" but with "gamma"? 

# e.g., let's use this new set of summary statistics borrowed from README
# - disease: Influenza 
# - epi_distribution: incubation_period
# - mean: 2.05
# - sd: 0.49

# show how to use convert functions
gamma_example <- gamma_meansd2shapescale(mean = 2.05,
                                         sd = 0.49)
gamma_example
#> $shape
#> [1] 17.50312
#> 
#> $scale
#> [1] 0.117122

# show how to use the output of convert functions within `epidist()`
epidist(
  disease = "influenza", 
  epi_dist= "incubation_period", 
  prob_distribution = "gamma",
  prob_distribution_params = c(shape = gamma_example$shape, 
                               scale = gamma_example$scale)
)
#> Citation cannot be created as either author, year or DOI is missing
#> Disease: influenza
#> Pathogen: NA
#> Epi Distribution: incubation period
#> Study: No citation available
#> Distribution: gamma
#> Parameters:
#>   shape: 17.503123698459
#>   rate: 8.5381091211995

Created on 2023-03-11 with reprex v2.0.2

Extraction functions can follow a similar path.

avallecam avatar Mar 11 '23 22:03 avallecam