Skip to content

assess to request using discrete distributions for generation time or discretize internally #312

@avallecam

Description

@avallecam

This is regarding the epiparameter-epichains interoperability. The current feature could lead to getting unwanted aggregate() outputs. I think {cfr} does internal discretisation when epiparameter is used as input.

Find below a reprex of the current behaviour with a default continuous and discretized epiparameter:

# default: continuous epiparameter ---------------------------------------

epiparameter_default <- epiparameter::epiparameter_db(
  disease = "mers",
  epi_name = "serial",
  single_epiparameter = TRUE
)
#> Using Cowling B, Park M, Fang V, Wu P, Leung G, Wu J (2015). "Preliminary
#> epidemiological assessment of MERS-CoV outbreak in South Korea, May to
#> June 2016." _Eurosurveillance_.
#> doi:10.2807/1560-7917.es2015.20.25.21163
#> <https://doi.org/10.2807/1560-7917.es2015.20.25.21163>.. 
#> To retrieve the citation use the 'get_citation' function

mers_chains <- epichains::simulate_chains(
  n_chains = 1000,
  statistic = "size",
  offspring_dist = rnbinom,
  mu = 0.6,
  size = 0.02,
  generation_time = as.function(epiparameter_default, func_type = "generate")
)

head(aggregate(mers_chains,by = "time"))
#>       time cases
#> 1 0.000000  1000
#> 2 6.196621     1
#> 3 6.804927     1
#> 4 6.872387     1
#> 5 7.041034     1
#> 6 7.160494     1


# discrete epiparameter --------------------------------------------------

epiparameter_discrete <- epiparameter::discretise(epiparameter_default)

mers_chains <- epichains::simulate_chains(
  n_chains = 1000,
  statistic = "size",
  offspring_dist = rnbinom,
  mu = 0.6,
  size = 0.02,
  generation_time = as.function(epiparameter_discrete, func_type = "generate")
)

head(aggregate(mers_chains,by = "time"))
#>   time cases
#> 1    0  1000
#> 2    6     1
#> 3    7     6
#> 4    8    21
#> 5    9    40
#> 6   10    56

Created on 2025-07-15 with reprex v2.1.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requestshort-termasap and before august 2025 ends

    Type

    No type

    Projects

    Status

    No status

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions