Package 'epidist'

Title: Estimate Epidemiological Delay Distributions With brms
Description: Understanding and accurately estimating epidemiological delay distributions is important for public health policy. These estimates directly influence epidemic situational awareness, control strategies, and resource allocation. In this package, we provide methods to address the key challenges in estimating these distributions, including truncation, interval censoring, and dynamical biases. Despite their importance, these issues are frequently overlooked, often resulting in biased conclusions.
Authors: Adam Howes [aut, cre] , Sang Woo Park [aut] , Sam Abbott [aut]
Maintainer: Adam Howes <[email protected]>
License: MIT + file LICENSE
Version: 0.0.0.9000
Built: 2025-01-21 13:33:26 UTC
Source: https://github.com/epinowcast/epidist

Help Index


Add natural scale mean and standard deviation parameters

Description

Add natural scale mean and standard deviation parameters

Usage

add_mean_sd(data, ...)

Arguments

data

A dataframe of distributional parameters

...

Additional arguments for method.

See Also

Other postprocess: add_mean_sd.default(), add_mean_sd.gamma_samples(), add_mean_sd.lognormal_samples(), predict_delay_parameters()


Default method for add natural scale parameters

Description

Default method for add natural scale parameters

Usage

## Default S3 method:
add_mean_sd(data, ...)

Arguments

data

A dataframe of distributional parameters

...

Additional arguments for method.

See Also

Other postprocess: add_mean_sd(), add_mean_sd.gamma_samples(), add_mean_sd.lognormal_samples(), predict_delay_parameters()


Add natural scale mean and standard deviation parameters for a latent gamma model

Description

Again, mu and shape here are the distributional parameters of brms.

Usage

## S3 method for class 'gamma_samples'
add_mean_sd(data, ...)

Arguments

data

A dataframe of distributional parameters

...

Additional arguments for method.

See Also

Other postprocess: add_mean_sd(), add_mean_sd.default(), add_mean_sd.lognormal_samples(), predict_delay_parameters()


Add natural scale mean and standard deviation parameters for a latent lognormal model

Description

Note that the input parameters here are mu and sigma, corresponding to the distributional parameters used by brms for the lognormal family.

Usage

## S3 method for class 'lognormal_samples'
add_mean_sd(data, ...)

Arguments

data

A dataframe of distributional parameters

...

Additional arguments for method.

See Also

Other postprocess: add_mean_sd(), add_mean_sd.default(), add_mean_sd.gamma_samples(), predict_delay_parameters()


Convert an object to an epidist_latent_model object

Description

Convert an object to an epidist_latent_model object

Usage

as_epidist_latent_model(data)

Arguments

data

An object to be converted to the class epidist_latent_model

See Also

Other latent_model: as_epidist_latent_model.epidist_linelist_data(), epidist_family_model.epidist_latent_model(), epidist_formula_model.epidist_latent_model(), epidist_gen_log_lik_latent(), is_epidist_latent_model(), new_epidist_latent_model()


The latent model method for epidist_linelist_data objects

Description

The latent model method for epidist_linelist_data objects

Usage

## S3 method for class 'epidist_linelist_data'
as_epidist_latent_model(data)

Arguments

data

An epidist_linelist_data object

See Also

Other latent_model: as_epidist_latent_model(), epidist_family_model.epidist_latent_model(), epidist_formula_model.epidist_latent_model(), epidist_gen_log_lik_latent(), is_epidist_latent_model(), new_epidist_latent_model()


Create an epidist_linelist_data object

Description

Create an epidist_linelist_data object

Usage

as_epidist_linelist_data(data, ...)

Arguments

data

The data to convert

...

Additional arguments passed to methods

See Also

Other linelist_data: as_epidist_linelist_data.data.frame(), as_epidist_linelist_data.default(), assert_epidist.epidist_linelist_data(), is_epidist_linelist_data(), new_epidist_linelist_data()


Create an epidist_linelist_data object from a data frame with event dates

Description

Create an epidist_linelist_data object from a data frame with event dates

Usage

## S3 method for class 'data.frame'
as_epidist_linelist_data(
  data,
  pdate_lwr = NULL,
  sdate_lwr = NULL,
  pdate_upr = NULL,
  sdate_upr = NULL,
  obs_date = NULL,
  ...
)

Arguments

data

A data.frame containing line list data

pdate_lwr

A string giving the column of data containing the primary event lower bound as a datetime. Defaults to NULL which assumes that the variable pdate_lwr is present.

sdate_lwr

A string giving the column of data containing the secondary event lower bound as a datetime. Defaults to NULL which assumes that the variable sdate_lwr is present.

pdate_upr

A string giving the column of data containing the primary event upper bound as a datetime. If this column exists in the data it will be used, otherwise if not supplied then the value of pdate_lwr + 1 day is used.

sdate_upr

A string giving the column of data containing the secondary event upper bound as a datetime. If this column exists in the data it will be used, otherwise if not supplied then the value of sdate_lwr + 1 day is used.

obs_date

A string giving the column of data containing the observation time as a datetime. Optional, if not supplied then the maximum of sdate_upr is used.

...

Additional arguments passed to methods

See Also

Other linelist_data: as_epidist_linelist_data(), as_epidist_linelist_data.default(), assert_epidist.epidist_linelist_data(), is_epidist_linelist_data(), new_epidist_linelist_data()


Create an epidist_linelist_data object from vectors of event times

Description

Create an epidist_linelist_data object from vectors of event times

Usage

## Default S3 method:
as_epidist_linelist_data(
  data,
  ptime_upr = NULL,
  stime_lwr = NULL,
  stime_upr = NULL,
  obs_time = NULL,
  ...
)

Arguments

data

Numeric vector giving lower bounds for primary times

ptime_upr

Numeric vector giving upper bounds for primary times

stime_lwr, stime_upr

Numeric vectors giving lower and upper bounds for secondary times

obs_time

Numeric vector giving observation times

...

Additional columns to add to the epidist_linelist_data object

See Also

Other linelist_data: as_epidist_linelist_data(), as_epidist_linelist_data.data.frame(), assert_epidist.epidist_linelist_data(), is_epidist_linelist_data(), new_epidist_linelist_data()


Prepare naive model to pass through to brms

Description

Prepare naive model to pass through to brms

Usage

as_epidist_naive_model(data)

Arguments

data

An object to be converted to the class epidist_naive_model

See Also

Other naive_model: as_epidist_naive_model.epidist_linelist_data(), is_epidist_naive_model(), new_epidist_naive_model()


The naive model method for epidist_linelist_data objects

Description

The naive model method for epidist_linelist_data objects

Usage

## S3 method for class 'epidist_linelist_data'
as_epidist_naive_model(data)

Arguments

data

An epidist_linelist_data object

See Also

Other naive_model: as_epidist_naive_model(), is_epidist_naive_model(), new_epidist_naive_model()


Validation for epidist objects

Description

Validation for epidist objects

Usage

assert_epidist(data, ...)

Arguments

data

Object to validate

...

Additional arguments

Value

NULL invisibly


Assert validity of epidist_linelist_data objects

Description

Assert validity of epidist_linelist_data objects

Usage

## S3 method for class 'epidist_linelist_data'
assert_epidist(data, ...)

Arguments

data

An object to check

...

Additional arguments

See Also

Other linelist_data: as_epidist_linelist_data(), as_epidist_linelist_data.data.frame(), as_epidist_linelist_data.default(), is_epidist_linelist_data(), new_epidist_linelist_data()


Fit epidemiological delay distributions using a brms interface

Description

Fit epidemiological delay distributions using a brms interface

Usage

epidist(data, formula, family, prior, fn, ...)

Arguments

data

An object with class corresponding to an implemented model.

formula

An object of class stats::formula or brms::brmsformula (or one that can be coerced to those classes). A symbolic description of the model to be fitted. A formula must be provided for the distributional parameter mu, and may optionally be provided for other distributional parameters.

family

A description of the response distribution and link function to be used in the model. Every family function has a link argument allowing users to specify the link function to be applied on the response variable. If not specified, default links are used. For details of all supported families see brmsfamily(). Commonly used, such as lognormal(), are also reexported as part of epidist.

prior

One or more brmsprior objects created by brms::set_prior() or related functions. These priors are passed to epidist_prior() in the prior argument.

fn

The internal function to be called. By default this is brms::brm() which performs inference for the specified model. Other options are brms::make_stancode() which returns the Stan code for the specified model, or brms::make_standata() which returns the data passed to Stan. These two later options may be useful for model debugging and extensions.

...

Additional arguments passed to fn method.

See Also

Other fit: epidist.default()


Diagnostics for epidist_fit models

Description

This function computes diagnostics to assess the quality of a fitted model. When the fitting algorithm used is "sampling" (HMC) then the output of epidist_diagnostics is a data.frame containing:

  • time: the total time taken to fit all chains

  • samples: the total number of samples across all chains

  • max_rhat: the highest value of the Gelman-Rubin statistic

  • divergent_transitions: the total number of divergent transitions

  • per_divergent_transitions: the proportion of samples which had divergent transitions

  • max_treedepth: the highest value of the treedepth HMC parameter

  • no_at_max_treedepth: the number of samples which attained the max_treedepth

  • per_at_max_treedepth: the proportion of samples which attained the max_treedepth

Usage

epidist_diagnostics(fit)

Arguments

fit

A fitted model of class epidist_fit

Details

When the fitting algorithm is not "sampling" (see brms::brm() for other possible algorithms) then diagnostics are yet to be implemented.


Define epidist family

Description

This function is used within epidist() to create a model specific custom brms family object. This custom family is passed to brms. It is unlikely that as a user you will need this function, but we export it nonetheless to be transparent about what happens inside of a call to epidist().

Usage

epidist_family(data, family = lognormal(), ...)

Arguments

data

An object with class corresponding to an implemented model.

family

A description of the response distribution and link function to be used in the model. Every family function has a link argument allowing users to specify the link function to be applied on the response variable. If not specified, default links are used. For details of all supported families see brmsfamily(). Commonly used, such as lognormal(), are also reexported as part of epidist.

...

Additional arguments passed to fn method.

See Also

Other family: epidist_family_model(), epidist_family_model.default(), epidist_family_reparam(), epidist_family_reparam.default(), epidist_family_reparam.gamma()


The model-specific parts of an epidist_family() call

Description

The model-specific parts of an epidist_family() call

The model-specific parts of an epidist_formula() call

Usage

epidist_family_model(data, family, ...)

epidist_formula_model(data, formula, ...)

Arguments

data

An object with class corresponding to an implemented model.

family

Output of a call to brms::brmsfamily() with additional information as provided by .add_dpar_info()

...

Additional arguments passed to fn method.

formula

An object of class stats::formula or brms::brmsformula (or one that can be coerced to those classes). A symbolic description of the model to be fitted. A formula must be provided for the distributional parameter mu, and may optionally be provided for other distributional parameters.

See Also

Other family: epidist_family(), epidist_family_model.default(), epidist_family_reparam(), epidist_family_reparam.default(), epidist_family_reparam.gamma()

Other formula: epidist_formula(), epidist_formula_model.default()


Default method for defining a model specific family

Description

Default method for defining a model specific family

Usage

## Default S3 method:
epidist_family_model(data, family, ...)

Arguments

data

An object with class corresponding to an implemented model.

family

Output of a call to brms::brmsfamily() with additional information as provided by .add_dpar_info()

...

Additional arguments passed to fn method.

See Also

Other family: epidist_family(), epidist_family_model(), epidist_family_reparam(), epidist_family_reparam.default(), epidist_family_reparam.gamma()


Create the model-specific component of an epidist custom family

Description

Create the model-specific component of an epidist custom family

Usage

## S3 method for class 'epidist_latent_model'
epidist_family_model(data, family, ...)

Arguments

data

An object with class corresponding to an implemented model.

family

Output of a call to brms::brmsfamily() with additional information as provided by .add_dpar_info()

...

Additional arguments passed to method.

See Also

Other latent_model: as_epidist_latent_model(), as_epidist_latent_model.epidist_linelist_data(), epidist_formula_model.epidist_latent_model(), epidist_gen_log_lik_latent(), is_epidist_latent_model(), new_epidist_latent_model()


Family specific prior distributions

Description

This function contains brms prior distributions which are specific to particular likelihood families e.g. brms::lognormal().

Usage

epidist_family_prior(family, ...)

Arguments

family

A description of the response distribution and link function to be used in the model. Every family function has a link argument allowing users to specify the link function to be applied on the response variable. If not specified, default links are used. For details of all supported families see brmsfamily(). Commonly used, such as lognormal(), are also reexported as part of epidist.

...

Additional arguments passed to fn method.

See Also

Other prior: epidist_family_prior.default(), epidist_family_prior.lognormal(), epidist_model_prior(), epidist_model_prior.default(), epidist_prior()


Default family specific prior distributions

Description

By default, we do not return any family specific prior distributions.

Usage

## Default S3 method:
epidist_family_prior(family, formula, ...)

Arguments

family

A description of the response distribution and link function to be used in the model. Every family function has a link argument allowing users to specify the link function to be applied on the response variable. If not specified, default links are used. For details of all supported families see brmsfamily(). Commonly used, such as lognormal(), are also reexported as part of epidist.

formula

An object of class stats::formula or brms::brmsformula (or one that can be coerced to those classes). A symbolic description of the model to be fitted. A formula must be provided for the distributional parameter mu, and may optionally be provided for other distributional parameters.

...

Additional arguments passed to fn method.

See Also

Other prior: epidist_family_prior(), epidist_family_prior.lognormal(), epidist_model_prior(), epidist_model_prior.default(), epidist_prior()


Family specific prior distributions for the lognormal family

Description

We suggest priors to overwrite the brms defaults for the lognormal family.

Usage

## S3 method for class 'lognormal'
epidist_family_prior(family, formula, ...)

Arguments

family

A description of the response distribution and link function to be used in the model. Every family function has a link argument allowing users to specify the link function to be applied on the response variable. If not specified, default links are used. For details of all supported families see brmsfamily(). Commonly used, such as lognormal(), are also reexported as part of epidist.

formula

An object of class stats::formula or brms::brmsformula (or one that can be coerced to those classes). A symbolic description of the model to be fitted. A formula must be provided for the distributional parameter mu, and may optionally be provided for other distributional parameters.

...

Additional arguments passed to fn method.

See Also

Other prior: epidist_family_prior(), epidist_family_prior.default(), epidist_model_prior(), epidist_model_prior.default(), epidist_prior()


Reparameterise an epidist family to align brms and Stan

Description

Reparameterise an epidist family to align brms and Stan

Usage

epidist_family_reparam(family, ...)

Arguments

family

A description of the response distribution and link function to be used in the model. Every family function has a link argument allowing users to specify the link function to be applied on the response variable. If not specified, default links are used. For details of all supported families see brmsfamily(). Commonly used, such as lognormal(), are also reexported as part of epidist.

...

Additional arguments passed to fn method.

See Also

Other family: epidist_family(), epidist_family_model(), epidist_family_model.default(), epidist_family_reparam.default(), epidist_family_reparam.gamma()


Default method for families which do not require a reparameterisation

Description

Default method for families which do not require a reparameterisation

Usage

## Default S3 method:
epidist_family_reparam(family, ...)

Arguments

family

A description of the response distribution and link function to be used in the model. Every family function has a link argument allowing users to specify the link function to be applied on the response variable. If not specified, default links are used. For details of all supported families see brmsfamily(). Commonly used, such as lognormal(), are also reexported as part of epidist.

...

Additional arguments passed to fn method.

See Also

Other family: epidist_family(), epidist_family_model(), epidist_family_model.default(), epidist_family_reparam(), epidist_family_reparam.gamma()


Reparameterisation for the gamma family

Description

Reparameterisation for the gamma family

Usage

## S3 method for class 'gamma'
epidist_family_reparam(family, ...)

Arguments

family

A description of the response distribution and link function to be used in the model. Every family function has a link argument allowing users to specify the link function to be applied on the response variable. If not specified, default links are used. For details of all supported families see brmsfamily(). Commonly used, such as lognormal(), are also reexported as part of epidist.

...

Additional arguments passed to fn method.

See Also

Other family: epidist_family(), epidist_family_model(), epidist_family_model.default(), epidist_family_reparam(), epidist_family_reparam.default()


Define a model specific formula

Description

This function is used within epidist() to create the formula object passed to brms. It is unlikely that as a user you will need this function, but we export it nonetheless to be transparent about what exactly is happening inside of a call to epidist().

Usage

epidist_formula(data, family, formula, ...)

Arguments

data

An object with class corresponding to an implemented model.

family

A description of the response distribution and link function to be used in the model created using epidist_family().

formula

An object of class stats::formula or brms::brmsformula (or one that can be coerced to those classes). A symbolic description of the model to be fitted. A formula must be provided for the distributional parameter mu, and may optionally be provided for other distributional parameters.

...

Additional arguments passed to fn method.

See Also

Other formula: epidist_family_model(), epidist_formula_model.default()


Default method for defining a model specific formula

Description

Default method for defining a model specific formula

Usage

## Default S3 method:
epidist_formula_model(data, formula, ...)

Arguments

data

An object with class corresponding to an implemented model.

formula

An object of class stats::formula or brms::brmsformula (or one that can be coerced to those classes). A symbolic description of the model to be fitted. A formula must be provided for the distributional parameter mu, and may optionally be provided for other distributional parameters.

...

Additional arguments passed to fn method.

See Also

Other formula: epidist_family_model(), epidist_formula()


Define the model-specific component of an epidist custom formula

Description

Define the model-specific component of an epidist custom formula

Usage

## S3 method for class 'epidist_latent_model'
epidist_formula_model(data, formula, ...)

Arguments

data

An object with class corresponding to an implemented model.

formula

An object of class stats::formula or brms::brmsformula (or one that can be coerced to those classes). A symbolic description of the model to be fitted. A formula must be provided for the distributional parameter mu, and may optionally be provided for other distributional parameters.

...

Additional arguments passed to method.

See Also

Other latent_model: as_epidist_latent_model(), as_epidist_latent_model.epidist_linelist_data(), epidist_family_model.epidist_latent_model(), epidist_gen_log_lik_latent(), is_epidist_latent_model(), new_epidist_latent_model()


Create a function to calculate the pointwise log likelihood of the latent model

Description

This function creates a log likelihood function that accounts for the latent variables in the model, including primary and secondary event windows and their overlap. The returned function calculates the log likelihood for a single observation by augmenting the data with the latent variables and using the underlying brms log likelihood function.

Usage

epidist_gen_log_lik_latent(family)

Arguments

family

A description of the response distribution and link function to be used in the model. Every family function has a link argument allowing users to specify the link function to be applied on the response variable. If not specified, default links are used. For details of all supported families see brmsfamily(). Commonly used, such as lognormal(), are also reexported as part of epidist.

Value

A function that calculates the log likelihood for a single observation. The prep object must have the following variables:

  • vreal1: relative observation time

  • vreal2: primary event window

  • vreal3: secondary event window

See Also

brms::log_lik() for details on the brms log likelihood interface.

Other latent_model: as_epidist_latent_model(), as_epidist_latent_model.epidist_linelist_data(), epidist_family_model.epidist_latent_model(), epidist_formula_model.epidist_latent_model(), is_epidist_latent_model(), new_epidist_latent_model()


Create a function to draw from the expected value of the posterior predictive distribution for a latent model

Description

This function creates a function that calculates the expected value of the posterior predictive distribution for a latent model. The returned function takes a prep argument (from brms) and returns posterior expected values. This is used internally by brms::posterior_epred() to calculate expected values for latent models.

Usage

epidist_gen_posterior_epred(family)

Arguments

family

A description of the response distribution and link function to be used in the model. Every family function has a link argument allowing users to specify the link function to be applied on the response variable. If not specified, default links are used. For details of all supported families see brmsfamily(). Commonly used, such as lognormal(), are also reexported as part of epidist.

Value

A function that takes a prep argument from brms and returns a matrix of posterior expected values, with one row per posterior draw and one column per observation.

See Also

brms::posterior_epred() for details on how this is used within brms.

Other gen: epidist_gen_posterior_predict()


Create a function to draw from the posterior predictive distribution for a latent model

Description

This function creates a function that draws from the posterior predictive distribution for a latent model using primarycensored::rpcens() to handle censoring and truncation. The returned function takes a prep argument from brms and returns posterior predictions. This is used internally by brms::posterior_predict() to generate predictions for latent models.

Usage

epidist_gen_posterior_predict(family)

Arguments

family

A description of the response distribution and link function to be used in the model. Every family function has a link argument allowing users to specify the link function to be applied on the response variable. If not specified, default links are used. For details of all supported families see brmsfamily(). Commonly used, such as lognormal(), are also reexported as part of epidist.

Value

A function that takes a prep argument from brms and returns a matrix of posterior predictions, with one row per posterior draw and one column per observation. The prep object must have the following variables:

  • vreal1: relative observation time

  • vreal2: primary event window

  • vreal3: secondary event window

See Also

brms::posterior_predict() for details on how this is used within brms, primarycensored::rpcens() for details on the censoring approach

Other gen: epidist_gen_posterior_epred()


Model specific prior distributions

Description

This function contains brms prior distributions which are specific to particular epidist models e.g. the latent_lognormal model.

Usage

epidist_model_prior(data, ...)

Arguments

data

An object with class corresponding to an implemented model.

...

Additional arguments passed to fn method.

See Also

Other prior: epidist_family_prior(), epidist_family_prior.default(), epidist_family_prior.lognormal(), epidist_model_prior.default(), epidist_prior()


Default model specific prior distributions

Description

By default, we do not return any model specific prior distributions.

Usage

## Default S3 method:
epidist_model_prior(data, formula, ...)

Arguments

data

An object with class corresponding to an implemented model.

formula

An object of class stats::formula or brms::brmsformula (or one that can be coerced to those classes). A symbolic description of the model to be fitted. A formula must be provided for the distributional parameter mu, and may optionally be provided for other distributional parameters.

...

Additional arguments passed to fn method.

See Also

Other prior: epidist_family_prior(), epidist_family_prior.default(), epidist_family_prior.lognormal(), epidist_model_prior(), epidist_prior()


Define prior distributions using brms defaults, model specific priors, family specific priors, and user provided priors

Description

This function obtains the brms default prior distributions for a particular model, then replaces these prior distributions using:

  1. Model specific prior distributions from epidist_model_prior()

  2. Family specific prior distributions from epidist_family_prior()

  3. User provided prior distributions Each element of this list overwrites previous elements, such that user provided prior distribution have the highest priority. At the third stage, if a prior distribution is provided which is not included in the model, then a warning will be shown. To prevent this warning, do not pass prior distributions for parameters which are not in the model.

Usage

epidist_prior(data, family, formula, prior)

Arguments

data

An object with class corresponding to an implemented model.

family

A description of the response distribution and link function to be used in the model created using epidist_family().

formula

A symbolic description of the model to be fitted created using epidist_formula().

prior

One or more brmsprior objects created by brms::set_prior() or related functions. These priors are passed to epidist_prior() in the prior argument.

See Also

Other prior: epidist_family_prior(), epidist_family_prior.default(), epidist_family_prior.lognormal(), epidist_model_prior(), epidist_model_prior.default()


Define model specific Stan code

Description

This function is used within epidist() to create any custom Stan code which is injected into brms via the stanvars argument. It is unlikely that as a user you will need this function, but we export it nonetheless to be transparent about what exactly is happening inside of a call to epidist().

Usage

epidist_stancode(data, ...)

Arguments

data

An object with class corresponding to an implemented model.

...

Additional arguments passed to fn method.

See Also

Other stan: epidist_stancode.default()


Default method for defining model specific Stan code

Description

Default method for defining model specific Stan code

Usage

## Default S3 method:
epidist_stancode(data, ...)

Arguments

data

An object with class corresponding to an implemented model.

...

Additional arguments passed to fn method.

See Also

Other stan: epidist_stancode()


Default method used for interface using brms

Description

Default method used for interface using brms

Usage

## Default S3 method:
epidist(
  data,
  formula = mu ~ 1,
  family = lognormal(),
  prior = NULL,
  fn = brms::brm,
  ...
)

Arguments

data

An object with class corresponding to an implemented model.

formula

An object of class stats::formula or brms::brmsformula (or one that can be coerced to those classes). A symbolic description of the model to be fitted. A formula must be provided for the distributional parameter mu, and may optionally be provided for other distributional parameters.

family

A description of the response distribution and link function to be used in the model. Every family function has a link argument allowing users to specify the link function to be applied on the response variable. If not specified, default links are used. For details of all supported families see brmsfamily(). Commonly used, such as lognormal(), are also reexported as part of epidist.

prior

One or more brmsprior objects created by brms::set_prior() or related functions. These priors are passed to epidist_prior() in the prior argument.

fn

The internal function to be called. By default this is brms::brm() which performs inference for the specified model. Other options are brms::make_stancode() which returns the Stan code for the specified model, or brms::make_standata() which returns the data passed to Stan. These two later options may be useful for model debugging and extensions.

...

Additional arguments passed to fn method.

See Also

Other fit: epidist()


Check if data has the epidist_latent_model class

Description

Check if data has the epidist_latent_model class

Usage

is_epidist_latent_model(data)

Arguments

data

An object

See Also

Other latent_model: as_epidist_latent_model(), as_epidist_latent_model.epidist_linelist_data(), epidist_family_model.epidist_latent_model(), epidist_formula_model.epidist_latent_model(), epidist_gen_log_lik_latent(), new_epidist_latent_model()


Check if data has the epidist_linelist_data class

Description

Check if data has the epidist_linelist_data class

Usage

is_epidist_linelist_data(data, ...)

Arguments

data

The data to convert

...

Additional arguments

See Also

Other linelist_data: as_epidist_linelist_data(), as_epidist_linelist_data.data.frame(), as_epidist_linelist_data.default(), assert_epidist.epidist_linelist_data(), new_epidist_linelist_data()


Check if data has the epidist_naive_model class

Description

Check if data has the epidist_naive_model class

Usage

is_epidist_naive_model(data)

Arguments

data

An object

See Also

Other naive_model: as_epidist_naive_model(), as_epidist_naive_model.epidist_linelist_data(), new_epidist_naive_model()


Class constructor for epidist_latent_model objects

Description

Class constructor for epidist_latent_model objects

Usage

new_epidist_latent_model(data)

Arguments

data

An object to be set with the class epidist_latent_model

Value

An object of class epidist_latent_model

See Also

Other latent_model: as_epidist_latent_model(), as_epidist_latent_model.epidist_linelist_data(), epidist_family_model.epidist_latent_model(), epidist_formula_model.epidist_latent_model(), epidist_gen_log_lik_latent(), is_epidist_latent_model()


Class constructor for epidist_linelist_data objects

Description

Class constructor for epidist_linelist_data objects

Usage

new_epidist_linelist_data(data)

Arguments

data

A data.frame to convert

Value

An object of class epidist_linelist_data

See Also

Other linelist_data: as_epidist_linelist_data(), as_epidist_linelist_data.data.frame(), as_epidist_linelist_data.default(), assert_epidist.epidist_linelist_data(), is_epidist_linelist_data()


Class constructor for epidist_naive_model objects

Description

Class constructor for epidist_naive_model objects

Usage

new_epidist_naive_model(data)

Arguments

data

An object to be set with the class epidist_naive_model

Value

An object of class epidist_naive_model

See Also

Other naive_model: as_epidist_naive_model(), as_epidist_naive_model.epidist_linelist_data(), is_epidist_naive_model()


Extract samples of the delay distribution parameters

Description

Extract samples of the delay distribution parameters

Usage

predict_delay_parameters(fit, newdata = NULL, ...)

predict_dpar(fit, newdata = NULL, ...)

Arguments

fit

A model fit with epidist()

newdata

An optional data.frame for which to evaluate predictions. If NULL (default), the original data of the model is used. NA values within factors (excluding grouping variables) are interpreted as if all dummy variables of this factor are zero. This allows, for instance, to make predictions of the grand mean when using sum coding. NA values within grouping variables are treated as a new level.

...

Additional arguments passed to brms::prepare_predictions()

See Also

Other postprocess: add_mean_sd(), add_mean_sd.default(), add_mean_sd.gamma_samples(), add_mean_sd.lognormal_samples()


Ebola linelist data from Fang et al. (2016)

Description

Linelist data for the Ebola virus collected in Sierra Leone. If you use this data in your work, please cite the corresponding paper.

Usage

sierra_leone_ebola_data

Format

A tibble with 8,358 rows and 8 columns:

id

Unique identification number for the case

name

Name as character, omitted

age

Age as numeric

sex

Sex as character, either "F", "M" or NA

date_of_symptom_onset

The date symptoms began

date_of_sample_tested

The date the sample was tested

district

The district (ADM2)

chiefdom

The chiefdom (ADM3)

Source

https://www.pnas.org/doi/full/10.1073/pnas.1518587113


Simulate exponential cases

Description

This function simulates cases from an exponential distribution. The user may specify the rate parameter r, the sample size, and the upper bound of the survival time. If the rate parameter is 0, then this function defaults to the uniform distribution.

Usage

simulate_exponential_cases(r = 0.2, sample_size = 10000, seed, t = 30)

Arguments

r

The exponential growth rate parameter. Defaults to 0.2.

sample_size

The number of cases to simulate. Defaults to 10000.

seed

The random seed to be used in the simulation process.

t

Upper bound of the survival time. Defaults to 30.

Value

A data.frame with two columns: case (case number) and ptime (primary event time).

See Also

Other simulate: simulate_gillespie(), simulate_secondary(), simulate_uniform_cases()


Simulate cases from a stochastic SIR model

Description

This function simulates cases from an stochastic SIR model. The user may specify the initial epidemic growth rate rr, the rate of recovery gamma γ\gamma, the initial number of infected cases I0I_0, and the total population size NN.

Usage

simulate_gillespie(r = 0.2, gamma = 1/7, I0 = 50, N = 10000, seed)

Arguments

r

The initial epidemic growth rate. Defaults to 0.2.

gamma

The rate of recovery. Defaults to 1/7.

I0

The initial number of infected people. Defaults to 50.

N

The total population size. Defaults to 10000.

seed

The random seed to be used in the simulation process.

Value

A data.frame with two columns: case (case number) and ptime (primary event time).

See Also

Other simulate: simulate_exponential_cases(), simulate_secondary(), simulate_uniform_cases()


Simulate secondary events based on a delay distribution

Description

This function simulates secondary events based on a given delay distribution. The input dataset should have the primary event times in a column named ptime.

Usage

simulate_secondary(data, dist = rlnorm, ...)

Arguments

data

A data frame with the primary event times.

dist

The delay distribution to be used. Defaults to rlnorm().

...

Arguments to be passed to the delay distribution function.

Value

A data.frame that augments data with two new columns: delay (secondary event latency) and stime (the time of the secondary event).

See Also

Other simulate: simulate_exponential_cases(), simulate_gillespie(), simulate_uniform_cases()


Simulate cases from a uniform distribution

Description

This function simulates cases from a uniform distribution, where the primary event times are uniformly distributed between 0 and t.

Usage

simulate_uniform_cases(sample_size = 1000, t = 60)

Arguments

sample_size

The number of cases to simulate.

t

Upper bound of the uniform distribution to generate primary event times.

Value

A data.frame with two columns: case (case number) and ptime (primary event time).

See Also

Other simulate: simulate_exponential_cases(), simulate_gillespie(), simulate_secondary()