Skip to contents

This function calculates the number of consecutive significant ("growth_warning") observations, grouping them accordingly. The result is stored in an S3 object of class tsd_threshold.

Uses data from a tsd_onset object (output from seasonal_onset()).

seasonal_onset() has to be run with arguments;

  • season_start

  • season_end

  • only_current_season = FALSE

Usage

consecutive_growth_warnings(onset_output)

Arguments

onset_output

A tsd_onset object returned from seasonal_onset().

Value

An object of class tsd_growth_warning, containing; A tibble of processed observations, the significant_counter column specifies when a sequence of significant observation starts and ends. The first number is how many subsequent observations will be significant.

Examples

# Generate simulated data of seasonal waves
sim_data <- generate_seasonal_data(
  years = 5,
  start_date = as.Date("2022-05-26"),
  trend_rate = 1.002,
  noise_overdispersion = 2,
  relative_epidemic_concentration = 3
)

# Estimate seasonal onset
tsd_onset <- seasonal_onset(
  tsd = sim_data,
  family = "quasipoisson",
  season_start = 21,
  season_end = 20,
  only_current_season = FALSE
)

# Get consecutive significant observations
consecutive_growth_warnings(tsd_onset)
#> # A tibble: 256 × 16
#>    reference_time observation season    growth_rate lower_growth_rate
#>    <date>               <dbl> <chr>           <dbl>             <dbl>
#>  1 2022-06-23             101 2022/2023      0.218             0.110 
#>  2 2022-06-30             113 2022/2023      0.226             0.130 
#>  3 2022-07-07             159 2022/2023      0.288             0.234 
#>  4 2022-07-14             152 2022/2023      0.200             0.111 
#>  5 2022-07-21             155 2022/2023      0.109             0.0310
#>  6 2022-07-28             201 2022/2023      0.111             0.0389
#>  7 2022-08-04             197 2022/2023      0.0725            0.0166
#>  8 2022-08-11             237 2022/2023      0.113             0.0699
#>  9 2022-08-18             196 2022/2023      0.0599           -0.0220
#> 10 2022-08-25             235 2022/2023      0.0314           -0.0287
#> # ℹ 246 more rows
#> # ℹ 11 more variables: upper_growth_rate <dbl>, growth_warning <lgl>,
#> #   sum_of_cases <dbl>, sum_of_cases_warning <lgl>, seasonal_onset_alarm <lgl>,
#> #   skipped_window <lgl>, converged <lgl>, counter <dbl>, changeFlag <lgl>,
#> #   groupID <int>, significant_counter <dbl>