Title: | Library of Epidemiological Parameters with Helper Functions and Classes |
---|---|
Description: | Library of epidemiological parameters for infectious diseases extracted from the literature, and a set of classes and helper functions for working with parameters. |
Authors: | Joshua W. Lambert [aut, cre, cph] , Adam Kucharski [aut, cph] , Carmen Tamayo [aut] , Hugo Gruson [ctb, rev] , Sebastian Funk [ctb] , Pratik Gupte [rev] , James M. Azam [rev] , Chris Hartgerink [rev] , Tim Taylor [rev] |
Maintainer: | Joshua W. Lambert <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.3.0.9000 |
Built: | 2024-11-27 15:23:24 UTC |
Source: | https://github.com/epiverse-trace/epiparameter |
<epiparameter>
objects into a single <epiparameter>
object.Combine a list of <epiparameter>
objects into a single <epiparameter>
with a mixture distribution [see distributional::dist_mixture()
].
The aggregated <epiparameter>
returned from aggregate()
can then be used
with the density()
, cdf()
, quantile()
and generate()
methods for the
combined distributions.
## S3 method for class 'multi_epiparameter' aggregate(x, weighting = c("equal", "sample_size", "custom"), ..., weights)
## S3 method for class 'multi_epiparameter' aggregate(x, weighting = c("equal", "sample_size", "custom"), ..., weights)
x |
A |
weighting |
A |
... |
dots Not used, will warn if extra arguments are passed to function. |
weights |
A |
The aggregate()
method requires that all <epiparameter>
objects are
parameterised with <distribution>
objects (from the distributional
package). This means that unparameterised (see is_parameterised()
) or
discretised (see discretise()
) distributions cannot be aggregated and the
function will error.
An <epiparameter>
object
ebola_si <- epiparameter_db(epi_name = "serial interval", disease = "ebola") aggregate(ebola_si)
ebola_si <- epiparameter_db(epi_name = "serial interval", disease = "ebola") aggregate(ebola_si)
<epiparameter>
objectConvert from an R object to an <epiparameter>
object. If conversion is not
possible the function will error.
as_epiparameter(x, ...)
as_epiparameter(x, ...)
x |
an object used to select a method. |
... |
dots Extra arguments to be passed to the method. |
To create the full citation the information from the article table from the
epireview package of the corresponding entry will need to be passed
to function via the ...
argument. The argument should be called article
,
as it will be matched by name by $
.
To specify a probability distribution pass a character
string to the
function via the ...
argument. The argument should be called
prob_distribution
. For example, to specify a gamma distribution:
as_epiparameter(x, prob_distribution = "gamma")
.
Warning: distributions specified via the prob_dist
argument will
overwrite the probability distribution specified in the x
argument. For
example, if the probability distribution is given in an epireview
entry and the prob_dist
argument is specified then the function may error
or return an unparameterised <epiparameter>
if the parameterisation becomes
incompatible.
Valid probability distributions are: "gamma"
, "lnorm"
, "weibull"
,
"nbinom"
, "geom"
, "pois"
, "norm"
, "exp"
.
An <epiparameter>
object or list of <epiparameter>
objects.
<data.frame>
to an <epiparameter>
objectConvert the tabular information in <data.frame>
to an <epiparameter>
.
If the information in the <data.frame>
cannot be converted into an
<epiparameter>
the function will error.
## S3 method for class 'data.frame' as_epiparameter(x, ...)
## S3 method for class 'data.frame' as_epiparameter(x, ...)
x |
A |
... |
dots Not used, extra arguments supplied will cause a warning. |
An <epiparameter>
object or list of <epiparameter>
objects.
ep <- epiparameter_db(single_epiparameter = TRUE) df <- as.data.frame(ep) ep <- as_epiparameter(df)
ep <- epiparameter_db(single_epiparameter = TRUE) df <- as.data.frame(ep) ep <- as_epiparameter(df)
as.data.frame()
method for <epiparameter>
classas.data.frame()
method for <epiparameter>
class
## S3 method for class 'epiparameter' as.data.frame(x, ...)
## S3 method for class 'epiparameter' as.data.frame(x, ...)
x |
An |
... |
dots Not used, extra arguments supplied will cause a warning. |
The <data.frame>
returned will contain some atomic columns (i.e. one
object per row), and other columns that are lists (i.e. multiple objects per
row). The list columns can contain lists or S3 objects (e.g. <bibentry>
object in the citation
column).
A <data.frame>
with a single row.
ep <- epiparameter_db(single_epiparameter = TRUE) as.data.frame(ep)
ep <- epiparameter_db(single_epiparameter = TRUE) as.data.frame(ep)
as.data.frame()
method for <multi_epiparameter>
classas.data.frame()
method for <multi_epiparameter>
class
## S3 method for class 'multi_epiparameter' as.data.frame(x, ...)
## S3 method for class 'multi_epiparameter' as.data.frame(x, ...)
x |
A |
... |
dots Not used, extra arguments supplied will cause a warning. |
The <data.frame>
returned will contain some atomic columns (i.e. one
object per row), and other columns that are lists (i.e. multiple objects per
row). The list columns can contain lists or S3 objects (e.g. <bibentry>
object in the citation
column).
A <data.frame>
with as many rows as length of input list.
db <- epiparameter_db() as.data.frame(db)
db <- epiparameter_db() as.data.frame(db)
as.function()
method for <epiparameter>
classConverts an <epiparameter>
object to a distribution function
(see epiparameter_distribution_functions), either probability density/mass
function, (density
), cumulative distribution function (cdf
), random
number generator (generate
), or quantile (quantile
).
## S3 method for class 'epiparameter' as.function(x, func_type = c("density", "cdf", "generate", "quantile"), ...)
## S3 method for class 'epiparameter' as.function(x, func_type = c("density", "cdf", "generate", "quantile"), ...)
x |
An |
func_type |
A single |
... |
dots Extra arguments to be passed to the method. |
The function returned takes a single required argument x
.
A function object.
ep <- epiparameter_db(single_epiparameter = TRUE) # by default it will convert to a density function f <- as.function(ep) # use function f(10) f <- as.function(ep, func_type = "cdf") f(10)
ep <- epiparameter_db(single_epiparameter = TRUE) # by default it will convert to a density function f <- as.function(ep) # use function f(10) f <- as.function(ep, func_type = "cdf") f(10)
<epiparameter>
objectAssert an object is a valid <epiparameter>
object
assert_epiparameter(x)
assert_epiparameter(x)
x |
An R object. |
Invisibly returns an <epiparameter>
. Called for side-effects
(errors when invalid <epiparameter>
object is provided).
ep <- epiparameter_db(single_epiparameter = TRUE) assert_epiparameter(ep) # example with invalid <epiparameter> ep$disease <- NULL try(assert_epiparameter(ep))
ep <- epiparameter_db(single_epiparameter = TRUE) assert_epiparameter(ep) # example with invalid <epiparameter> ep$disease <- NULL try(assert_epiparameter(ep))
c()
method for <epiparameter>
classc()
method for <epiparameter>
class
## S3 method for class 'epiparameter' c(...) ## S3 method for class 'multi_epiparameter' c(...)
## S3 method for class 'epiparameter' c(...) ## S3 method for class 'multi_epiparameter' c(...)
... |
dots Objects to be concatenated. |
An <epiparameter>
or list of <epiparameter>
objects.
db <- epiparameter_db() # combine two <epiparameter> objects into a list c(db[[1]], db[[2]]) # combine a list of <epiparameter> objects and a single <epiparameter> object c(db, db[[1]])
db <- epiparameter_db() # combine two <epiparameter> objects into a list c(db[[1]], db[[2]]) # combine a list of <epiparameter> objects and a single <epiparameter> object c(db, db[[1]])
This function can be used in cases where the data on a fitted
distribution is not openly available and the summary statistics of the
distribution are not reported so the data are scraped from the plot and
the quantiles are needed in order use the extract_param()
function.
calc_disc_dist_quantile(prob, days, quantile)
calc_disc_dist_quantile(prob, days, quantile)
prob |
A |
days |
A |
quantile |
A single |
A named vector of quantiles.
prob <- dgamma(seq(0, 10, length.out = 21), shape = 2, scale = 2) days <- seq(0, 10, 0.5) quantiles <- c(0.025, 0.975) calc_disc_dist_quantile(prob = prob, days = days, quantile = quantiles)
prob <- dgamma(seq(0, 10, length.out = 21), shape = 2, scale = 2) days <- seq(0, 10, 0.5) quantiles <- c(0.025, 0.975) calc_disc_dist_quantile(prob = prob, days = days, quantile = quantiles)
Convert the parameters for a range of distributions to a number of summary statistics. All summary statistics are calculated analytically given the parameters.
convert_params_to_summary_stats(x, ...) ## S3 method for class 'character' convert_params_to_summary_stats( x = c("lnorm", "gamma", "weibull", "nbinom", "geom"), ... ) ## S3 method for class 'epiparameter' convert_params_to_summary_stats(x, ...)
convert_params_to_summary_stats(x, ...) ## S3 method for class 'character' convert_params_to_summary_stats( x = c("lnorm", "gamma", "weibull", "nbinom", "geom"), ... ) ## S3 method for class 'epiparameter' convert_params_to_summary_stats(x, ...)
x |
An R object. |
... |
< |
The distribution names and parameter names follow the style of
distributions in R, for example the lognormal distribution is lnorm
,
and its parameters are meanlog
and sdlog
.
A list of eight elements including: mean, median, mode,
variance (var
), standard deviation (sd
), coefficient of variation (cv
),
skewness, and excess kurtosis (ex_kurtosis
).
convert_summary_stats_to_params()
# example using characters convert_params_to_summary_stats("lnorm", meanlog = 1, sdlog = 2) convert_params_to_summary_stats("gamma", shape = 1, scale = 1) convert_params_to_summary_stats("nbinom", prob = 0.5, dispersion = 2) # example using <epiparameter> epiparameter <- epiparameter_db(single_epiparameter = TRUE) convert_params_to_summary_stats(epiparameter) # example using <epiparameter> and specifying parameters epiparameter <- epiparameter_db( disease = "Influenza", author = "Virlogeux", subset = prob_dist == "weibull" ) convert_params_to_summary_stats(epiparameter[[2]], shape = 1, scale = 1)
# example using characters convert_params_to_summary_stats("lnorm", meanlog = 1, sdlog = 2) convert_params_to_summary_stats("gamma", shape = 1, scale = 1) convert_params_to_summary_stats("nbinom", prob = 0.5, dispersion = 2) # example using <epiparameter> epiparameter <- epiparameter_db(single_epiparameter = TRUE) convert_params_to_summary_stats(epiparameter) # example using <epiparameter> and specifying parameters epiparameter <- epiparameter_db( disease = "Influenza", author = "Virlogeux", subset = prob_dist == "weibull" ) convert_params_to_summary_stats(epiparameter[[2]], shape = 1, scale = 1)
Convert the summary statistics for a range of distributions to the distribution's parameters. Most summary statistics are calculated analytically given the parameters. An exception is the Weibull distribution which uses a root finding numerical method.
convert_summary_stats_to_params(x, ...) ## S3 method for class 'character' convert_summary_stats_to_params( x = c("lnorm", "gamma", "weibull", "nbinom", "geom"), ... ) ## S3 method for class 'epiparameter' convert_summary_stats_to_params(x, ...)
convert_summary_stats_to_params(x, ...) ## S3 method for class 'character' convert_summary_stats_to_params( x = c("lnorm", "gamma", "weibull", "nbinom", "geom"), ... ) ## S3 method for class 'epiparameter' convert_summary_stats_to_params(x, ...)
x |
An R object. |
... |
< |
Summary statistics should be named accordingly (case-sensitive):
mean: mean
median: median
mode: mode
variance: var
standard deviation: sd
coefficient of variation: cv
skewness: skewness
excess kurtosis: ex_kurtosis
Note: Not all combinations of summary statistics can be converted into distribution parameters. In this case the function will error stating that the parameters cannot be calculated from the given input.
The distribution names and parameter names follow the style of
distributions in R, for example the lognormal distribution is lnorm
,
and its parameters are meanlog
and sdlog
.
A list of either one or two elements (depending on how many parameters the distribution has).
convert_params_to_summary_stats()
# examples using characters convert_summary_stats_to_params("lnorm", mean = 1, sd = 1) convert_summary_stats_to_params("weibull", mean = 2, var = 2) convert_summary_stats_to_params("geom", mean = 2) # examples using <epiparameter> epiparameter <- epiparameter_db(single_epiparameter = TRUE) convert_summary_stats_to_params(epiparameter) # example using <epiparameter> and specifying summary stats epiparameter$summary_stats <- list() convert_summary_stats_to_params(epiparameter, mean = 10, sd = 2)
# examples using characters convert_summary_stats_to_params("lnorm", mean = 1, sd = 1) convert_summary_stats_to_params("weibull", mean = 2, var = 2) convert_summary_stats_to_params("geom", mean = 2) # examples using <epiparameter> epiparameter <- epiparameter_db(single_epiparameter = TRUE) convert_summary_stats_to_params(epiparameter) # example using <epiparameter> and specifying summary stats epiparameter$summary_stats <- list() convert_summary_stats_to_params(epiparameter, mean = 10, sd = 2)
<epiparameter>
objectA helper function when creating an <epiparameter>
object to
create a citation list with sensible defaults, type checking and arguments
to help remember which citation information is accepted in the list.
create_citation( author = utils::person(), year = NA_integer_, title = NA_character_, journal = NA_character_, doi = NA_character_, pmid = NA_integer_ )
create_citation( author = utils::person(), year = NA_integer_, title = NA_character_, journal = NA_character_, doi = NA_character_, pmid = NA_integer_ )
author |
Either a |
year |
A |
title |
A |
journal |
A |
doi |
A |
pmid |
A |
This function acts as a wrapper around bibentry()
to create
citations for sources reporting epidemiological parameters.
A <bibentry>
object of the citation
create_citation( author = person(given = "John", family = "Smith"), year = 2002, title = "COVID-19 incubation period", journal = "Epi Journal", doi = "10.19832/j.1366-9516.2012.09147.x" )
create_citation( author = person(given = "John", family = "Smith"), year = 2002, title = "COVID-19 incubation period", journal = "Epi Journal", doi = "10.19832/j.1366-9516.2012.09147.x" )
A helper function when creating an <epiparameter>
object to
create a metadata list with sensible defaults, type checking and arguments
to help remember metadata list structure (element names).
create_metadata( units = NA_character_, sample_size = NA_integer_, region = NA_character_, transmission_mode = NA_character_, vector = NA_character_, extrinsic = FALSE, inference_method = NA_character_ )
create_metadata( units = NA_character_, sample_size = NA_integer_, region = NA_character_, transmission_mode = NA_character_, vector = NA_character_, extrinsic = FALSE, inference_method = NA_character_ )
units |
A |
sample_size |
The sample of the data used to fit the delay distribution. This is usually the number of people with data on a primary and possibly secondary event of interest. In cases where the sample size is not stated NA can be used. |
region |
The geographical location the data was collected. This can either be given at sub-national, national, continental. Multiple nested regions can be given and are comma separated. When the region is not specified NA can be given. |
transmission_mode |
A character string specifying how the pathogen is
transmitted. This information is used to determine whether the
epidemiological parameters are from a vector-borne disease (i.e. is
transmitted between humans through an intermediate vector), this is specified
by |
vector |
The name of the vector transmitting the vector-borne disease. This can be a common name, or a latin binomial name of a specific vector species. Both the common name and taxonomic name can be given with one given in parentheses. When a disease is not vector-borne NA should be given. |
extrinsic |
A boolean value defining whether the data entry is an extrinsic delay distribution, such as the extrinsic incubation period. This field is required because intrinsic and extrinsic delay distributions are stored as separate entries in the database and can be linked. When the disease is not vector-borne FALSE should be given. See Details for explanation of extrinsic distribution. |
inference_method |
The type of inference used to fit the delay distribution to the data. Abbreviations of model fitting techniques can be specified as long as they are non-ambiguous. This field is only used to determine whether the uncertainty intervals possibly specified in the other fields are: confidence intervals (in the case of maximum likelihood), or credible intervals (in the case of bayesian inference). Uncertainty bounds for another types of inference methods, or if the inference method is unstated are assumed to be confidence intervals. When the inference method is unknown or a disease does not have a probability distribution NA can be given. |
In vector-borne diseases the transmissibility of a disease is dependent on both the time taken for a host (i.e. human) to become infectious, but also on the time it takes the vector to become infectious. Therefore, the extrinsic delay, in which the vector has been infected by is not yet infectious can have a role in the spread of a disease.
A named list containing information on the sample size of the study, geography, whether the disease is vector-borne and if so whether it is the intrinsic or extrinsic distribution as well as method of distribution parameter estimation.
# it will automatically populate the fields with defaults if left empty create_metadata() # supplying each field create_metadata( units = "days", sample_size = 10, region = "UK", transmission_mode = "vector_borne", vector = "mosquito", extrinsic = FALSE, inference_method = "MLE" )
# it will automatically populate the fields with defaults if left empty create_metadata() # supplying each field create_metadata( units = "days", sample_size = 10, region = "UK", transmission_mode = "vector_borne", vector = "mosquito", extrinsic = FALSE, inference_method = "MLE" )
A helper function when creating an <epiparameter>
object to
create a method assessment list with sensible defaults, type checking and
arguments to help remember which method assessments can be accepted in
the list.
create_method_assess( censored = NA, right_truncated = NA, phase_bias_adjusted = NA )
create_method_assess( censored = NA, right_truncated = NA, phase_bias_adjusted = NA )
censored |
A boolean |
right_truncated |
A boolean |
phase_bias_adjusted |
A boolean |
Currently, the method assessment focuses on common methodological aspects of delay distributions (e.g. incubation period, serial interval, etc.), and does not currently take into account methodological aspects which may be important when fitting offspring distributions to data on disease (super)spreading.
A named list with three elements
create_method_assess( censored = FALSE, right_truncated = FALSE, phase_bias_adjusted = FALSE )
create_method_assess( censored = FALSE, right_truncated = FALSE, phase_bias_adjusted = FALSE )
Creates an S3 class holding the distribution and parameters from the probability distribution name, its parameters and distribution truncation and discretisation.
The class holding the distribution depends on whether it is a discretised distribution. For continuous and discrete distributions S3 classes from the distributional package are used, for discretised continuous distributions the an S3 class from the distcrete package is used.
For details on the properties of the distribution classes
from each respective package see their documentation (either
?distributional
or ?distcrete
)
create_prob_distribution( prob_distribution, prob_distribution_params, discretise = FALSE, truncation = NA, ... )
create_prob_distribution( prob_distribution, prob_distribution_params, discretise = FALSE, truncation = NA, ... )
prob_distribution |
A |
prob_distribution_params |
A named vector of probability distribution parameters. |
discretise |
A boolean |
truncation |
A |
... |
dots Extra arguments to be passed to
distributional or distcrete functions that construct the S3
distribution objects. To see which arguments can be adjusted for discretised
distributions see |
Truncation is enabled only for continuous distributions as there is no truncation implemented in distcrete.
By default the discretisation of continuous distributions uses a
discretisation interval (interval
) of 1. If the unit of the distribution
is days, then this will be discretised by day. The endpoint weighting (w
)
for the discretisation is 1. w
can be [0,1]
. For more information please
see distcrete::distcrete()
.
An S3 class containing the probability distribution or a character
string if the parameters of the probability distribution are unknown.
# example with continuous distribution without truncation create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1), discretise = FALSE, truncation = NA ) # example with continuous distribution with truncation create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1), discretise = FALSE, truncation = 10 ) # example with discrete distribution create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1), discretise = TRUE, truncation = NA ) # example passing extra arguments to distcrete create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1), discretise = TRUE, truncation = NA, w = 0.5 )
# example with continuous distribution without truncation create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1), discretise = FALSE, truncation = NA ) # example with continuous distribution with truncation create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1), discretise = FALSE, truncation = 10 ) # example with discrete distribution create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1), discretise = TRUE, truncation = NA ) # example passing extra arguments to distcrete create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1), discretise = TRUE, truncation = NA, w = 0.5 )
The geography of the data set can be a single geographical region at either continent, country, region or city level. By specifying the level of the geography the other fields may be deduced.
create_region( continent = NA_character_, country = NA_character_, region = NA_character_, city = NA_character_ )
create_region( continent = NA_character_, country = NA_character_, region = NA_character_, city = NA_character_ )
continent |
A |
country |
A |
region |
A |
city |
A |
A named list.
create_region(country = "UK")
create_region(country = "UK")
A helper function when creating an <epiparameter>
object to
create a summary statistics list with sensible defaults, type checking
and arguments to help remember which summary statistics can be accepted in
the list.
create_summary_stats( mean = NA_real_, mean_ci_limits = c(NA_real_, NA_real_), mean_ci = NA_real_, sd = NA_real_, sd_ci_limits = c(NA_real_, NA_real_), sd_ci = NA_real_, median = NA_real_, median_ci_limits = c(NA_real_, NA_real_), median_ci = NA_real_, dispersion = NA_real_, dispersion_ci_limits = c(NA_real_, NA_real_), dispersion_ci = NA_real_, lower_range = NA_real_, upper_range = NA_real_, quantiles = NA_real_ )
create_summary_stats( mean = NA_real_, mean_ci_limits = c(NA_real_, NA_real_), mean_ci = NA_real_, sd = NA_real_, sd_ci_limits = c(NA_real_, NA_real_), sd_ci = NA_real_, median = NA_real_, median_ci_limits = c(NA_real_, NA_real_), median_ci = NA_real_, dispersion = NA_real_, dispersion_ci_limits = c(NA_real_, NA_real_), dispersion_ci = NA_real_, lower_range = NA_real_, upper_range = NA_real_, quantiles = NA_real_ )
mean |
A |
mean_ci_limits |
A |
mean_ci |
A |
sd |
A |
sd_ci_limits |
A |
sd_ci |
A |
median |
A |
median_ci_limits |
A |
median_ci |
A |
dispersion |
A |
dispersion_ci_limits |
A |
dispersion_ci |
A |
lower_range |
The lower range of the data, used to infer the parameters of the distribution when not provided. |
upper_range |
The upper range of the data, used to infer the parameters of the distribution when not provided. |
quantiles |
A |
A list of summary statistics. The output list has element names equal to the function arguments:
$mean $mean_ci_limits $mean_ci $sd $sd_ci_limits $sd_ci $median $median_ci_limits $median_ci $dispersion $dispersion_ci_limits $dispersion_ci $lower_range $upper_range $quantiles
# mean and standard deviation create_summary_stats(mean = 5, sd = 2) # mean and standard deviation with uncertainty create_summary_stats( mean = 4, mean_ci_limits = c(2.1, 5.7), mean_ci = 95, sd = 0.7, sd_ci_limits = c(0.3, 1.1), sd_ci = 95 ) # median and range create_summary_stats( median = 5, lower_range = 1, upper_range = 13 )
# mean and standard deviation create_summary_stats(mean = 5, sd = 2) # mean and standard deviation with uncertainty create_summary_stats( mean = 4, mean_ci_limits = c(2.1, 5.7), mean_ci = 95, sd = 0.7, sd_ci_limits = c(0.3, 1.1), sd_ci = 95 ) # median and range create_summary_stats( median = 5, lower_range = 1, upper_range = 13 )
A helper function when creating uncertainty for the parameters
of the distribution for the <epiparameter>
object.
create_uncertainty(ci_limits = NA_real_, ci, ci_type)
create_uncertainty(ci_limits = NA_real_, ci, ci_type)
ci_limits |
A numeric vector of length two with the lower and upper bound of the confidence interval or credible interval. |
ci |
A numeric specifying the interval for the ci, e.g. 95 is 95% ci. |
ci_type |
A character string, either |
List of three elements:
$ci_limits
is the upper and lower bounds
of the CI (either confidence interval or credible interval) (i.e. a two
element numeric vector).
$ci
the interval (e.g. 95 is 95% CI) given by a
single numeric.
$ci_type
a character string specifying the type of
uncertainty (can be either "confidence interval"
or "credible interval"
).
# example with uncertainty for a single parameter create_uncertainty( ci_limits = c(1, 3), ci = 95, ci_type = "confidence interval" ) # example for multiple parameters # lengh of list should match number of parameters list( shape = create_uncertainty( ci_limits = c(1, 3), ci = 95, ci_type = "confidence interval" ), scale = create_uncertainty( ci_limits = c(2, 4), ci = 95, ci_type = "confidence interval" ) ) # example with unknown uncertainty # the function can be called without arguments create_uncertainty() # or give NA as the first argument create_uncertainty(NA)
# example with uncertainty for a single parameter create_uncertainty( ci_limits = c(1, 3), ci = 95, ci_type = "confidence interval" ) # example for multiple parameters # lengh of list should match number of parameters list( shape = create_uncertainty( ci_limits = c(1, 3), ci = 95, ci_type = "confidence interval" ), scale = create_uncertainty( ci_limits = c(2, 4), ci = 95, ci_type = "confidence interval" ) ) # example with unknown uncertainty # the function can be called without arguments create_uncertainty() # or give NA as the first argument create_uncertainty(NA)
<epiparameter>
objectDiscretises a continuous distribution in an <epiparameter>
object
discretise(x, ...) discretize(x, ...) ## S3 method for class 'epiparameter' discretise(x, ...) ## Default S3 method: discretise(x, ...)
discretise(x, ...) discretize(x, ...) ## S3 method for class 'epiparameter' discretise(x, ...) ## Default S3 method: discretise(x, ...)
x |
An |
... |
dots Extra arguments to be passed to the method. |
Converts the S3 distribution object in an <epiparameter>
from
continuous (using an object from the {distributional}
package) to a
discretised distribution (using an object from the {distcrete}
package).
An <epiparameter>
object.
ebola_incubation <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) ) discretise(ebola_incubation)
ebola_incubation <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) ) discretise(ebola_incubation)
<epiparameter>
objectThe <epiparameter>
class is used to store epidemiological
parameters for a single disease. These epidemiological parameters cover a
variety of aspects including delay distributions (e.g. incubation periods
and serial intervals, among others) and offspring distributions.
The <epiparameter>
object is the functional unit provided by
{epiparameter}
to plug into epidemiological pipelines. Obtaining an
<epiparameter>
object can be achieved in two main ways:
The epidemiological distribution is stored in
the {epiparameter}
library and can be accessed by epiparameter_db()
.
The alternative method is when you have information
(e.g. disease and distribution parameter estimates) and would like to input
this into an <epiparameter>
object in order to work in existing analysis
pipelines. This is where the epiparameter()
function can be used to fill
out each field for which information is known.
epiparameter( disease, pathogen = NA_character_, epi_name, prob_distribution = create_prob_distribution(prob_distribution = NA_character_), uncertainty = create_uncertainty(), summary_stats = create_summary_stats(), citation = create_citation(), metadata = create_metadata(), method_assess = create_method_assess(), notes = NULL, auto_calc_params = TRUE, ... )
epiparameter( disease, pathogen = NA_character_, epi_name, prob_distribution = create_prob_distribution(prob_distribution = NA_character_), uncertainty = create_uncertainty(), summary_stats = create_summary_stats(), citation = create_citation(), metadata = create_metadata(), method_assess = create_method_assess(), notes = NULL, auto_calc_params = TRUE, ... )
disease |
A |
pathogen |
A |
epi_name |
A |
prob_distribution |
An S3 class containing the probability
distribution or a character string if the parameters of the probability
distribution are unknown but the name of the distribution is known, or |
uncertainty |
A list of named vectors with the uncertainty around
the probability distribution parameters. If uncertainty around the parameter
estimates is unknown use |
summary_stats |
A list of summary statistics, use
|
citation |
A |
metadata |
A list of metadata, this can include: units, sample size,
the transmission mode of the disease (e.g. is it vector-borne or directly
transmitted), etc. It is assumed that the disease is not
vector-borne and that the distribution is intrinsic (e.g. not an extrinsic
delay distribution such as extrinsic incubation period) unless
|
method_assess |
A list of methodological aspects used when fitting
the distribution, use |
notes |
A |
auto_calc_params |
A boolean |
... |
dots Extra arguments to be passed to internal functions. This is most commonly used to pass arguments to |
Accepted <epiparameter>
distribution parameterisations are:
Gamma must be either 'shape' and 'scale' or 'shape' and 'rate'
Weibull must be 'shape' and 'scale'
Lognormal must be 'meanlog' and 'sdlog' or 'mu' and 'sigma'
Negative Binomial must be either 'mean' and 'dispersion' or 'n' and 'p'
Geometric must be either 'mean' or 'prob'
Poisson must be 'mean'
An <epiparameter>
object.
# minimal input required for `epiparameter` ebola_incubation <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) ) # minimal input required for discrete `epiparameter` ebola_incubation <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1), discretise = TRUE ) ) # example with more fields filled in ebola_incubation <- epiparameter( disease = "ebola", pathogen = "ebola_virus", epi_name = "incubation", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1), discretise = FALSE, truncation = NA ), uncertainty = list( shape = create_uncertainty(), scale = create_uncertainty() ), summary_stats = create_summary_stats(mean = 2, sd = 1), citation = create_citation( author = person(given = "John", family = "Smith"), year = 2002, title = "COVID-19 incubation period", journal = "Epi Journal", doi = "10.19832/j.1366-9516.2012.09147.x" ), metadata = create_metadata( units = "days", sample_size = 10, region = "UK", transmission_mode = "natural_human_to_human", inference_method = "MLE" ), method_assess = create_method_assess( censored = TRUE ), notes = "No notes" )
# minimal input required for `epiparameter` ebola_incubation <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) ) # minimal input required for discrete `epiparameter` ebola_incubation <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1), discretise = TRUE ) ) # example with more fields filled in ebola_incubation <- epiparameter( disease = "ebola", pathogen = "ebola_virus", epi_name = "incubation", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1), discretise = FALSE, truncation = NA ), uncertainty = list( shape = create_uncertainty(), scale = create_uncertainty() ), summary_stats = create_summary_stats(mean = 2, sd = 1), citation = create_citation( author = person(given = "John", family = "Smith"), year = 2002, title = "COVID-19 incubation period", journal = "Epi Journal", doi = "10.19832/j.1366-9516.2012.09147.x" ), metadata = create_metadata( units = "days", sample_size = 10, region = "UK", transmission_mode = "natural_human_to_human", inference_method = "MLE" ), method_assess = create_method_assess( censored = TRUE ), notes = "No notes" )
<epiparameter>
object(s) directly from the epiparameter library
(database)Extract <epiparameter>
object(s) directly from
the library of epidemiological parameters. The epiparameter
library of epidemiological parameters is compiled from primary literature
sources. The list output from epiparameter_db()
can be subset by the data
it contains, for example by: disease, pathogen, epidemiological distribution,
sample size, region, etc.
If a distribution from a specific study is required, the author
argument
can be specified.
Multiple entries (<epiparameter>
objects) can be returned, use the
arguments to subset entries and use single_epiparameter = TRUE
to force a
single <epiparameter>
to be returned.
epiparameter_db( disease = "all", pathogen = "all", epi_name = "all", author = NULL, subset = NULL, single_epiparameter = FALSE )
epiparameter_db( disease = "all", pathogen = "all", epi_name = "all", author = NULL, subset = NULL, single_epiparameter = FALSE )
disease |
A |
pathogen |
A |
epi_name |
A |
author |
A |
subset |
Either Subsetting (using The The expression should be specified without using the data object name
(e.g. |
single_epiparameter |
A boolean Note: If multiple entries match the arguments supplied and
|
disease
, epi_name
and author
are given as individual arguments
as these are the most common variables to subset the parameter library by.
The subset
argument facilitates all other subsetting of rows to select the
<epiparameter>
object(s) desired. To subset based on multiple variables
separate each expression with &
.
List of epidemiological parameters:
"all" (default, returns all entries in library)
"incubation period"
"onset to hospitalisation"
"onset to death"
"serial interval"
"generation time"
"offspring distribution"
"hospitalisation to death"
"hospitalisation to discharge"
"notification to death"
"notification to discharge"
"onset to discharge"
"onset to ventilation"
An <epiparameter>
object or list of <epiparameter>
objects.
epiparameter_db(disease = "influenza", epi_name = "serial_interval") # example using custom subsetting eparam <- epiparameter_db( disease = "SARS", epi_name = "offspring_distribution", subset = sample_size > 40 ) # example using functional subsetting eparam <- epiparameter_db( disease = "COVID-19", epi_name = "incubation_period", subset = is_parameterised ) # example forcing a single <epiparameter> to be returned eparam <- epiparameter_db( disease = "SARS", epi_name = "offspring_distribution", single_epiparameter = TRUE )
epiparameter_db(disease = "influenza", epi_name = "serial_interval") # example using custom subsetting eparam <- epiparameter_db( disease = "SARS", epi_name = "offspring_distribution", subset = sample_size > 40 ) # example using functional subsetting eparam <- epiparameter_db( disease = "COVID-19", epi_name = "incubation_period", subset = is_parameterised ) # example forcing a single <epiparameter> to be returned eparam <- epiparameter_db( disease = "SARS", epi_name = "offspring_distribution", single_epiparameter = TRUE )
<epiparameter>
objectsThe <epiparameter>
object holds a probability distribution
which can either be a continuous or discrete distribution. These are the
density, cumulative distribution, quantile and random number generation
functions. These operate on any distribution that can be included in an
<epiparameter>
object.
## S3 method for class 'epiparameter' density(x, at, ...) ## S3 method for class 'epiparameter' cdf(x, q, ..., log = FALSE) ## S3 method for class 'epiparameter' quantile(x, p, ...) ## S3 method for class 'epiparameter' generate(x, times, ...)
## S3 method for class 'epiparameter' density(x, at, ...) ## S3 method for class 'epiparameter' cdf(x, q, ..., log = FALSE) ## S3 method for class 'epiparameter' quantile(x, p, ...) ## S3 method for class 'epiparameter' generate(x, times, ...)
x |
An |
at |
The quantiles to evaluate at. |
... |
dots Extra arguments to be passed to the method. |
q |
The quantiles to evaluate at. |
log |
If |
p |
The probabilities to evaluate at. |
times |
The number of random samples. |
numeric
vector.
ep <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) ) # example of each distribution method for an `epiparameter` object stats::density(ep, at = 1) distributional::cdf(ep, q = 1) stats::quantile(ep, p = 0.2) distributional::generate(ep, times = 10)
ep <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) ) # example of each distribution method for an `epiparameter` object stats::density(ep, at = 1) distributional::cdf(ep, q = 1) stats::quantile(ep, p = 0.2) distributional::generate(ep, times = 10)
Options to modify the printing of epiparameter objects.
Currently options are only used to modify the printing of the
<multi_epiparameter>
class.
epiparameter_options
epiparameter_options
An object of class list
of length 2.
Options are set with options()
and retrieved with getOption()
.
If options are changed the epiparameter package will need to be
reloaded for new options to be taken into account. Options can be set in
the .Rprofile
to persist across R sessions.
character
strings with the core column names of the
epidemiological parameter data exported by the epireview R package.A vector of character
strings with the core column names of the
epidemiological parameter data exported by the epireview R package.
epireview_core_cols
epireview_core_cols
epireview_core_cols
A character
vector with 58
elements.
The data is taken as the intersection of the column names of each of the disease parameter tables in the epireview R package.
https://github.com/mrc-ide/epireview
Summary data of distributions, as provided by reports and meta-analyses, can be used to extract the parameters of a chosen distribution. Currently available distributions are: lognormal, gamma, Weibull and normal. Extracting from a lognormal returns the meanlog and sdlog parameters, extracting from the gamma and Weibull returns the shape and scale parameters, and extracting from the normal returns the mean and sd parameters.
extract_param( type = c("percentiles", "range"), values, distribution = c("lnorm", "gamma", "weibull", "norm"), percentiles, samples, control = list(max_iter = 1000, tolerance = 1e-05) )
extract_param( type = c("percentiles", "range"), values, distribution = c("lnorm", "gamma", "weibull", "norm"), percentiles, samples, control = list(max_iter = 1000, tolerance = 1e-05) )
type |
A |
values |
A |
distribution |
A |
percentiles |
A |
samples |
A |
control |
A named list containing options for the optimisation. List
element |
For gamma
, lnorm
and weibull
, extract_param()
works only
for strictly positive values at the percentiles of a distribution or the
median and range of data (numerics supplied to the values
argument).
This means that negative values at the lower percentile or lower range
will not work with this function although they may present themselves in
epidemiological data (e.g. negative serial interval). For the norm
distribution negative values are allowed.
A named numeric
vector with the parameter values of the
distribution. If the distribution = lnorm
then the parameters returned are
the meanlog and sdlog; if the distribution = gamma
or distribution = weibull
then the parameters returned are the shape and scale; if
distribution = norm
then the parameters returned are mean and sd.
Adam Kucharski, Joshua W. Lambert
# set seed to control for stochasticity set.seed(1) # extract parameters of a lognormal distribution from the 75 percentiles extract_param( type = "percentiles", values = c(6, 13), distribution = "lnorm", percentiles = c(0.125, 0.875) ) # extract parameters of a gamma distribution from median and range extract_param( type = "range", values = c(10, 3, 18), distribution = "gamma", samples = 20 )
# set seed to control for stochasticity set.seed(1) # extract parameters of a lognormal distribution from the 75 percentiles extract_param( type = "percentiles", values = c(6, 13), distribution = "lnorm", percentiles = c(0.125, 0.875) ) # extract parameters of a gamma distribution from median and range extract_param( type = "range", values = c(10, 3, 18), distribution = "gamma", samples = 20 )
<epiparameter>
classThe family()
function is used to extract the distribution
names from objects from {distributional}
and {distcrete}
. This method
provides the same interface for <epiparameter>
objects to give consistent
output irrespective of the internal distribution class.
## S3 method for class 'epiparameter' family(object, ..., base_dist = FALSE)
## S3 method for class 'epiparameter' family(object, ..., base_dist = FALSE)
object |
An |
... |
further arguments passed to methods. |
base_dist |
A boolean |
A character string with the name of the distribution, or NA
when
the <epiparameter>
object is unparameterised.
# example with continuous distribution ep <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) ) family(ep) # example with discretised distribution ep <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "lnorm", prob_distribution_params = c(meanlog = 1, sdlog = 1), discretise = TRUE ) ) family(ep)
# example with continuous distribution ep <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) ) family(ep) # example with discretised distribution ep <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "lnorm", prob_distribution_params = c(meanlog = 1, sdlog = 1), discretise = TRUE ) ) family(ep)
<epiparameter>
classFormat method for <epiparameter>
class
## S3 method for class 'epiparameter' format(x, ...)
## S3 method for class 'epiparameter' format(x, ...)
x |
An |
... |
dots Extra arguments to be passed to the method. |
Invisibly returns an <epiparameter>
. Called for printing
side-effects.
epiparameter <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) ) format(epiparameter)
epiparameter <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) ) format(epiparameter)
Extract the citation stored in an R object.
get_citation(x, ...)
get_citation(x, ...)
x |
an object used to select a method. |
... |
dots Extra arguments to be passed to the method. |
<epiparameter>
objectExtract the citation stored in an <epiparameter>
object.
## S3 method for class 'epiparameter' get_citation(x, ...)
## S3 method for class 'epiparameter' get_citation(x, ...)
x |
An |
... |
dots Not used, extra arguments supplied will cause a warning. |
A <bibentry>
object.
# example with <epiparameter> ep <- epiparameter_db(single_epiparameter = TRUE) get_citation(ep) # example returning bibtex format ep <- epiparameter_db(disease = "COVID-19", single_epiparameter = TRUE) cit <- get_citation(ep) format(cit, style = "bibtex")
# example with <epiparameter> ep <- epiparameter_db(single_epiparameter = TRUE) get_citation(ep) # example returning bibtex format ep <- epiparameter_db(disease = "COVID-19", single_epiparameter = TRUE) cit <- get_citation(ep) format(cit, style = "bibtex")
<epiparameter>
objectsExtract the citation stored in a list of <epiparameter>
objects.
## S3 method for class 'multi_epiparameter' get_citation(x, ...)
## S3 method for class 'multi_epiparameter' get_citation(x, ...)
x |
An |
... |
dots Not used, extra arguments supplied will cause a warning. |
A <bibentry>
object containing multiple references. The length of
output <bibentry>
is equal to the length of the list of <epiparameter>
objects supplied.
# example with list of <epiparameter> db <- epiparameter_db() get_citation(db)
# example with list of <epiparameter> db <- epiparameter_db() get_citation(db)
Extract the parameters stored in an R object.
get_parameters(x, ...)
get_parameters(x, ...)
x |
an object used to select a method. |
... |
dots Extra arguments to be passed to the method. |
<epiparameter>
objectExtract the parameters of the distribution stored in an <epiparameter>
object.
## S3 method for class 'epiparameter' get_parameters(x, ...) ## S3 method for class 'multi_epiparameter' get_parameters(x, ...)
## S3 method for class 'epiparameter' get_parameters(x, ...) ## S3 method for class 'multi_epiparameter' get_parameters(x, ...)
x |
An |
... |
dots Not used, extra arguments supplied will cause a warning. |
The <epiparameter>
object can be unparameterised in which it lacks
a probability distribution or parameters of a probability distribution,
in this case the get_parameters.epiparameter()
method will return NA
.
A named vector of parameters or NA
when the <epiparameter>
object is unparameterised.
ep <- epiparameter_db( disease = "COVID-19", epi_name = "serial interval", single_epiparameter = TRUE ) get_parameters(ep)
ep <- epiparameter_db( disease = "COVID-19", epi_name = "serial interval", single_epiparameter = TRUE ) get_parameters(ep)
<epiparameter>
is continuousCheck if distribution in <epiparameter>
is continuous
is_continuous(x)
is_continuous(x)
x |
An |
The <epiparameter>
class can hold <distribution>
and
<distcrete>
probability distribution objects from the distributional
package and the distcrete package, respectively. <distribution>
objects can be continuous or discrete distributions (e.g. gamma or negative
binomial), and all <distcrete>
objects are discrete.
A boolean logical
.
ep <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "lnorm", prob_distribution_params = c(meanlog = 1, sdlog = 1) ) ) is_continuous(ep) is_continuous(discretise(ep)) ep <- epiparameter( disease = "ebola", epi_name = "offspring distribution", prob_distribution = create_prob_distribution( prob_distribution = "nbinom", prob_distribution_params = c(mean = 2, dispersion = 0.5) ) ) is_continuous(ep)
ep <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "lnorm", prob_distribution_params = c(meanlog = 1, sdlog = 1) ) ) is_continuous(ep) is_continuous(discretise(ep)) ep <- epiparameter( disease = "ebola", epi_name = "offspring distribution", prob_distribution = create_prob_distribution( prob_distribution = "nbinom", prob_distribution_params = c(mean = 2, dispersion = 0.5) ) ) is_continuous(ep)
<epiparameter>
Check object is an <epiparameter>
is_epiparameter(x)
is_epiparameter(x)
x |
An R object. |
A boolean logical, TRUE
if the object is an <epiparameter>
and FALSE
if not.
ep <- epiparameter( disease = "ebola", epi_name = "serial_interval", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) ) is_epiparameter(ep) false_ep <- list( disease = "ebola", epi_name = "serial_interval", prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) is_epiparameter(false_ep)
ep <- epiparameter( disease = "ebola", epi_name = "serial_interval", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) ) is_epiparameter(ep) false_ep <- list( disease = "ebola", epi_name = "serial_interval", prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) is_epiparameter(false_ep)
Check whether the vector of parameters for the probability distribution are in the set of possible parameters used in the epiparameter package
is_epiparameter_params(prob_distribution, prob_distribution_params)
is_epiparameter_params(prob_distribution, prob_distribution_params)
prob_distribution |
A |
prob_distribution_params |
A named vector of probability distribution parameters. |
This check for valid parameters is independent of whether the distribution is truncated or discretised.
A boolean logical
.
is_epiparameter_params( prob_distribution = "gamma", prob_distribution_params = c(shape = 2, scale = 1) )
is_epiparameter_params( prob_distribution = "gamma", prob_distribution_params = c(shape = 2, scale = 1) )
<epiparameter>
or list of <epiparameter>
objects contains a
distribution and distribution parametersCheck if <epiparameter>
or list of <epiparameter>
objects contains a
distribution and distribution parameters
is_parameterised(x, ...) is_parameterized(x, ...) ## S3 method for class 'epiparameter' is_parameterised(x, ...) ## S3 method for class 'multi_epiparameter' is_parameterised(x, ...)
is_parameterised(x, ...) is_parameterized(x, ...) ## S3 method for class 'epiparameter' is_parameterised(x, ...) ## S3 method for class 'multi_epiparameter' is_parameterised(x, ...)
x |
An |
... |
dots Extra arguments to be passed to the method. |
A single boolean logical
for <epiparameter>
or vector of
logical
s equal in length to the list of <epiparameter>
objects input.
If the <epiparameter>
object is missing either a probability distribution
or parameters for the probability distribution returns FALSE
, otherwise it
returns TRUE
.
# parameterised <epiparameter> ep <- epiparameter( disease = "ebola", epi_name = "incubation", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) ) is_parameterised(ep) # unparameterised <epiparameter> ep <- epiparameter( disease = "ebola", epi_name = "incubation" ) is_parameterised(ep) # list of <epiparameter> db <- epiparameter_db() is_parameterised(db)
# parameterised <epiparameter> ep <- epiparameter( disease = "ebola", epi_name = "incubation", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) ) is_parameterised(ep) # unparameterised <epiparameter> ep <- epiparameter( disease = "ebola", epi_name = "incubation" ) is_parameterised(ep) # list of <epiparameter> db <- epiparameter_db() is_parameterised(db)
<epiparameter>
is truncatedCheck if distribution in <epiparameter>
is truncated
is_truncated(x)
is_truncated(x)
x |
An |
The <epiparameter>
class can hold probability distribution objects
from the {distributional}
package or the {distcrete}
package,
however, only distribution objects from {distributional}
can be truncated.
If a <epiparameter>
object has a <distcrete>
object is_truncated
will
return FALSE
by default.
A boolean logical
.
ep <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "lnorm", prob_distribution_params = c(meanlog = 1, sdlog = 1) ) ) is_truncated(ep) ep <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "lnorm", prob_distribution_params = c(meanlog = 1, sdlog = 1), truncation = 10 ) ) is_truncated(ep)
ep <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "lnorm", prob_distribution_params = c(meanlog = 1, sdlog = 1) ) ) is_truncated(ep) ep <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "lnorm", prob_distribution_params = c(meanlog = 1, sdlog = 1), truncation = 10 ) ) is_truncated(ep)
<epiparameter>
classMean method for <epiparameter>
class
## S3 method for class 'epiparameter' mean(x, ...)
## S3 method for class 'epiparameter' mean(x, ...)
x |
An |
... |
dots Not used, extra arguments supplied will cause a warning. |
A numeric
mean of a distribution or NA
.
ep <- epiparameter_db( disease = "COVID-19", epi_name = "incubation period", single_epiparameter = TRUE ) mean(ep)
ep <- epiparameter_db( disease = "COVID-19", epi_name = "incubation period", single_epiparameter = TRUE ) mean(ep)
This function subsets the epidemiological parameter library to return only the chosen epidemiological distribution. The results are returned as a data frame containing the disease, epidemiological distribution, probability distribution, author of the study, and the year of publication.
parameter_tbl( multi_epiparameter, disease = "all", pathogen = "all", epi_name = "all" )
parameter_tbl( multi_epiparameter, disease = "all", pathogen = "all", epi_name = "all" )
multi_epiparameter |
Either an |
disease |
A |
pathogen |
A |
epi_name |
A |
A <parameter_tbl>
object which is a subclass of <data.frame>
.
Joshua W. Lambert, Adam Kucharski
epiparameter_list <- epiparameter_db(disease = "COVID-19") parameter_tbl(multi_epiparameter = epiparameter_list) # example filtering an existing list to incubation periods epiparameter_list <- epiparameter_db(disease = "COVID-19") parameter_tbl( multi_epiparameter = epiparameter_list, epi_name = "incubation period" )
epiparameter_list <- epiparameter_db(disease = "COVID-19") parameter_tbl(multi_epiparameter = epiparameter_list) # example filtering an existing list to incubation periods epiparameter_list <- epiparameter_db(disease = "COVID-19") parameter_tbl( multi_epiparameter = epiparameter_list, epi_name = "incubation period" )
<epiparameter>
classPlot an <epiparameter>
object by displaying the either the
probability mass function (PMF), (in the case of discrete distributions)
or probability density function (PDF) (in the case of continuous
distributions), or the cumulative distribution function (CDF).
## S3 method for class 'epiparameter' plot(x, cumulative = FALSE, ...)
## S3 method for class 'epiparameter' plot(x, cumulative = FALSE, ...)
x |
An |
cumulative |
A boolean |
... |
further arguments passed to or from other methods. |
By default if the xlim
argument is not specified the distribution is
plotted between day 0 and the 99th quantile of the distribution.
Alternatively, a numeric
vector of length 2 with the
first and last day to plot on the x-axis can be supplied to xlim
(through ...).
Joshua W. Lambert
# plot continuous epiparameter ep <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 2, scale = 1) ) ) plot(ep) # plot different day range (x-axis) plot(ep, xlim = c(0, 10)) # plot CDF plot(ep, cumulative = TRUE) # plot discrete epiparameter ep <- discretise(ep) plot(ep)
# plot continuous epiparameter ep <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 2, scale = 1) ) ) plot(ep) # plot different day range (x-axis) plot(ep, xlim = c(0, 10)) # plot CDF plot(ep, cumulative = TRUE) # plot discrete epiparameter ep <- discretise(ep) plot(ep)
<epiparameter>
classPrint method for <epiparameter>
class
## S3 method for class 'epiparameter' print(x, ...)
## S3 method for class 'epiparameter' print(x, ...)
x |
An |
... |
dots Extra arguments to be passed to the method. |
Invisibly returns an <epiparameter>
. Called for side-effects.
epiparameter <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) ) epiparameter
epiparameter <- epiparameter( disease = "ebola", epi_name = "incubation_period", prob_distribution = create_prob_distribution( prob_distribution = "gamma", prob_distribution_params = c(shape = 1, scale = 1) ) ) epiparameter
<multi_epiparameter>
classPrint method for <multi_epiparameter>
class
## S3 method for class 'multi_epiparameter' print(x, ..., n = NULL)
## S3 method for class 'multi_epiparameter' print(x, ..., n = NULL)
x |
A |
... |
dots Extra arguments to be passed to the method. |
n |
A |
Invisibly returns a <multi_epiparameter>
. Called for side-effects.
# entire database db <- epiparameter_db() db # a single disease db <- epiparameter_db(disease = "Ebola") db # a single epi parameter db <- epiparameter_db(epi_name = "offspring distribution") db
# entire database db <- epiparameter_db() db # a single disease db <- epiparameter_db(disease = "Ebola") db # a single epi parameter db <- epiparameter_db(epi_name = "offspring distribution") db
<epiparameter>
objectTest whether an object is a valid <epiparameter>
object
test_epiparameter(x)
test_epiparameter(x)
x |
An R object. |
A boolean logical
whether the object is a valid <epiparameter>
object (prints message when invalid <epiparameter>
object is provided).
ep <- epiparameter_db(single_epiparameter = TRUE) test_epiparameter(ep) # example with invalid <epiparameter> ep$disease <- NULL test_epiparameter(ep)
ep <- epiparameter_db(single_epiparameter = TRUE) test_epiparameter(ep) # example with invalid <epiparameter> ep$disease <- NULL test_epiparameter(ep)