epi_convolve | R Documentation |
Perform a convolution given a pdf
epi_convolve(cases, pdf, direction = "forward")
cases |
numeric, the observed cases |
pdf |
numeric vector, the pdf of cases |
direction |
string, one of forward or backwards convolution |
{
true_cases <- rpois(100, 5)
out <- data.frame(reported = ceiling(epi_convolve(true_cases, pdf = c(.2,.2,.3,.2,.1))),
true_cases,
date = 1:100
)
library(ggplot2)
ggplot(out, aes(date))+
geom_line(aes(y = true_cases))+
geom_line(aes(y = reported), color = "blue")
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.