fit_gamma_incubation_dist {epitrix} | R Documentation |
Fit discrite gamma distribution to incubation periods
Description
A wrapper around fit_disc_gamma to fit a discrete gamma distribution to incubation periods derived from exposure and onset dates. Can take into account uncertain dates of exposure.
Usage
fit_gamma_incubation_dist(
x,
date_of_onset,
exposure,
exposure_end = NULL,
nsamples = 1000,
...
)
Arguments
x |
the linelist data (data.frame or linelist object) containing at least a column containing the exposure dates and one containing the onset dates. |
date_of_onset |
the name of the column containing the onset dates (bare variable name or in quotes) |
exposure |
the name of the column containing the exposure dates (bare variable name or in quotes) |
exposure_end |
the name of a column containing dates representing the end of the exposure period. This is 'NULL' by default, indicating all exposures are known and in the 'exposure' column. |
nsamples |
The number of samples to draw from the empirical distribution to fit on (dafaults to 1000) |
... |
passed to fit_disc_gamma |
Value
see [fit_disc_gamma()]
Author(s)
Flavio Finger, flavio.finger@lshtm.ac.uk
Examples
random_dates <- as.Date("2020-01-01") + sample(0:30, 50, replace = TRUE)
x <- data.frame(date_of_onset = random_dates)
mkexposures <- function(x) x - round(rgamma(sample.int(5, size = 1), shape = 12, rate = 3))
exposures <- sapply(x$date_of_onset, mkexposures)
x$date_exposure <- exposures
fit <- fit_gamma_incubation_dist(x, date_of_onset, date_exposure)
plot(0:20, fit$distribution$d(0:20),
type = "h", lwd = 10, lend = 2, col = "#49D193",
xlab = "Days since exposure",
ylab = "Probability",
main = "Incubation time distribution")