fit_gamma_incubation_dist.Rd
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.
fit_gamma_incubation_dist(x, date_of_onset, exposure, exposure_end = NULL, nsamples = 1000, ...)
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 |
see [fit_disc_gamma()]
x <- linelist::clean_data(linelist::messy_data()) mkexposures <- function(x) x - round(rgamma(sample.int(5, size = 1), shape = 12, rate = 3)) exposures <- sapply(x$date_of_onset, mkexposures) x$dates_exposure <- exposures fit <- fit_gamma_incubation_dist(x, date_of_onset, dates_exposure)