# 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.
seq_bayes(cases, mu = 5 / 7)
# Obtain R0 when the serial distribution has a mean of three days.
seq_bayes(cases, mu = 3 / 7)
# Obtain R0 when the serial distribution has a mean of seven days, and R0 is
# believed to be at most 4.
estimate <- seq_bayes(cases, mu = 1, kappa = 4)
# Same as above, but return the posterior distribution of R0 instead of the
# estimate.
posterior <- seq_bayes(cases, mu = 1, kappa = 4, post = TRUE)
# Display the support and probability mass function of the posterior.
posterior$supp
posterior$pmf
# Note that the following always holds:
estimate == sum(posterior$supp * posterior$pmf)
Run the code above in your browser using DataLab