## ----setup, include = FALSE---------------------------------------------------
knitr::opts_chunk$set(collapse = TRUE, comment = "#>",
                      fig.width = 7, fig.height = 4, dev = "png")

## ----delay-fit----------------------------------------------------------------
library(survinger)
data(sarscov2_surveillance)

design <- surv_design(
  data = sarscov2_surveillance$sequences,
  strata = ~ region,
  sequencing_rate = sarscov2_surveillance$population[c("region", "seq_rate")],
  population = sarscov2_surveillance$population
)

delay_fit <- surv_estimate_delay(design, distribution = "negbin")
print(delay_fit)
plot(delay_fit)

## ----report-prob--------------------------------------------------------------
days <- c(7, 14, 21, 28)
probs <- surv_reporting_probability(delay_fit, delta = days)
data.frame(days_ago = days, prob_reported = round(probs, 3))

## ----nowcast, fig.cap = "Observed (grey bars) vs nowcasted (orange line) counts for BA.2.86"----
nowcast <- surv_nowcast_lineage(design, delay_fit, "BA.2.86")
plot(nowcast)

## ----adjusted-----------------------------------------------------------------
adjusted <- surv_adjusted_prevalence(design, delay_fit, "BA.2.86")
print(adjusted)

