Create an approximate confidence band for the Rt or incidence estimate. Note that the variance computation is approximate.
Usage
confband(object, lambda, level = 0.95, type = c("Rt", "Yt"), ...)
Arguments
- object
a
poisson_rt
orcv_poisson_rt
object.- lambda
the selected lambda. May be a scalar value, or in the case of
cv_poisson_rt
objects,"lambda.min"
or"lambda.max"
.- level
the desired confidence level(s). These will be sorted if necessary.
- type
the type
Rt
orYt
for confidence intervals of fitted Rt or fitted incident cases- ...
additional arguments for methods. Unused.
Value
A data.frame
containing the estimates Rt
or Yt
at the chosen
lambda
, and confidence limits corresponding to level
Examples
y <- c(1, rpois(100, dnorm(1:100, 50, 15) * 500 + 1))
out <- estimate_rt(y, nsol = 10)
head(confband(out, out$lambda[2]))
#> An `rt_confidence_band` object.
#>
#> * type = Rt
#> * lambda = 104.395
#> * degrees of freedom = 4
#>
#> # A tibble: 6 × 3
#> fit `2.5%` `97.5%`
#> <dbl> <dbl> <dbl>
#> 1 0.775 NaN NaN
#> 2 0.826 0.153 1.50
#> 3 0.877 0.0217 1.73
#> 4 0.928 0.0318 1.82
#> 5 0.978 0 1.96
#> 6 1.03 0 2.09
head(confband(out, out$lambda[2], level = c(0.95, 0.8, 0.5)))
#> An `rt_confidence_band` object.
#>
#> * type = Rt
#> * lambda = 104.395
#> * degrees of freedom = 4
#>
#> # A tibble: 6 × 7
#> fit `2.5%` `10.0%` `25.0%` `75.0%` `90.0%` `97.5%`
#> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 0.775 NaN NaN NaN NaN NaN NaN
#> 2 0.826 0.153 0.388 0.596 1.06 1.26 1.50
#> 3 0.877 0.0217 0.321 0.585 1.17 1.43 1.73
#> 4 0.928 0.0318 0.345 0.622 1.23 1.51 1.82
#> 5 0.978 0 0.342 0.644 1.31 1.61 1.96
#> 6 1.03 0 0.337 0.665 1.39 1.72 2.09
cv <- cv_estimate_rt(y, nfold = 3, nsol = 30)
head(confband(cv, "lambda.min", c(0.5, 0.9)))
#> An `rt_confidence_band` object.
#>
#> * type = Rt
#> * lambda = 22.892
#> * degrees of freedom = 4
#>
#> # A tibble: 6 × 5
#> fit `5%` `25%` `75%` `95%`
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 0.688 NaN NaN NaN NaN
#> 2 0.753 0.0900 0.483 1.02 1.42
#> 3 0.820 0.0560 0.509 1.13 1.58
#> 4 0.888 0.134 0.581 1.20 1.64
#> 5 0.957 0.113 0.613 1.30 1.80
#> 6 1.03 0.0612 0.632 1.42 1.99