# Weekly data.
cases <- c(1, 4, 10, 5, 3, 4, 19, 3, 3, 14, 4)
# Obtain R0 when the serial distribution has a mean of five days.
wp(cases, mu = 5 / 7)
# Obtain R0 when the serial distribution has a mean of three days.
wp(cases, mu = 3 / 7)
# Obtain R0 when the serial distribution is unknown.
# Note that this will take longer to run than when `mu` is known.
wp(cases)
# Same as above, but specify custom grid search parameters. The larger any of
# the parameters, the longer the search will take, but with potentially more
# accurate estimates.
wp(cases, grid_length = 40, max_shape = 4, max_scale = 4)
# Return the estimated serial distribution in addition to the estimate of R0.
estimate <- wp(cases, serial = TRUE)
# Display the estimate of R0, as well as the support and probability mass
# function of the estimated serial distribution returned by the grid search.
estimate$r0
estimate$supp
estimate$pmf
Run the code above in your browser using DataLab