Simulate death event on a daily basis in the given time period, according to user-specified distribution and parameters.
This function aims to simulate deaths event when they took place, not when they were registered. Each data point contains an ID and a date (date of event).
The simulated data is typically used for aggregation into different time granularities such as weekly or quarterly, for further modelling tasks.
Arguments
- start_date
Starting date of the simulation period. Date is in the format of 'yyyy-mm-dd'.
- end_date
Ending date of the simulation period.
- model
Model to simulate number of death event on each day from. Two models have been included: Poisson model and Gaussian approximation model. See details.
For Poisson model,
model = 'poisson'
.For Gaussian approximation model,
model = 'norm_approx'
.- param_list
List of parameters to control the simulation.
For Poisson model,
param_list = list(lambda = lambda)
.For Gaussian model,
param_list = list(mu = mu, sigma = sigma)
.
Value
A data.table containing
- id
Pseudo ID for death events.
- date
Date of the death event when it took place.
Details
This function simulates daily death event for an arbitrary location and time period. Given a starting and ending date, it first generates number of events on each day, based on a probability distribution or a generating function.
Generally, the user needs to specify the expected number of daily event (and standard deviation, when appropriate).
For Poisson model, the parameter is \(\lambda\).
For Gaussian model (with approximation), the parameters are \(\mu\) and \(\sigma\). Note that the generated numbers are rounded to the nearest integer and truncated at zero.
Future implementations
For simulating daily death event directly from distributions, we plan to include negative binomial model as an extension to the Poisson model.
We also plan to include the simulation with seasonality and trend.
Examples
start_date <- '2018-01-01'
end_date <- '2019-12-31'
# poisson model with mean daily death 25
death_event <- simulate_daily_death_event(
start_date = start_date,
end_date = end_date,
model = 'poisson',
param_list = list(lambda = 25))
# Gaussian model (approximation) with mean daily death 25, standard deviation 2
death_event <- simulate_daily_death_event(
start_date = start_date,
end_date = end_date,
model = 'norm_approx',
param_list = list(mu = 25, sigma = 2))