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 = 106.962
#> * degrees of freedom = 4
#>
#> # A tibble: 6 × 3
#> fit `2.5%` `97.5%`
#> <dbl> <dbl> <dbl>
#> 1 0.842 0 2.33
#> 2 0.887 0 1.81
#> 3 0.932 0.0111 1.85
#> 4 0.977 0 1.99
#> 5 1.02 0 2.10
#> 6 1.06 0 2.14
head(confband(out, out$lambda[2], level = c(0.95, 0.8, 0.5)))
#> An `rt_confidence_band` object.
#>
#> * type = Rt
#> * lambda = 106.962
#> * 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.842 0 0 0.336 1.35 1.81 2.33
#> 2 0.887 0 0.289 0.573 1.20 1.49 1.81
#> 3 0.932 0.0111 0.333 0.618 1.25 1.53 1.85
#> 4 0.977 0 0.321 0.633 1.32 1.63 1.99
#> 5 1.02 0 0.322 0.654 1.39 1.72 2.10
#> 6 1.06 0 0.363 0.696 1.43 1.76 2.14
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 = 23.455
#> * degrees of freedom = 4
#>
#> # A tibble: 6 × 5
#> fit `5%` `25%` `75%` `95%`
#> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 0.779 0 0.290 1.27 1.98
#> 2 0.839 0.0489 0.517 1.16 1.63
#> 3 0.899 0.0625 0.558 1.24 1.74
#> 4 0.960 0.0856 0.604 1.32 1.83
#> 5 1.02 0.0836 0.638 1.40 1.96
#> 6 1.08 0.0938 0.678 1.48 2.07