Skip to contents

[Stable]

This function performs automated and early detection of seasonal epidemic onsets (aedseo) on a time series dataset. It estimates growth rates for consecutive time intervals and calculates the sum of cases (sum_of_cases).

Usage

aedseo(
  tsd,
  k = 5,
  level = 0.95,
  disease_threshold = NA_integer_,
  family = c("poisson", "quasipoisson")
)

Arguments

tsd

A aedseo_tsd object containing time series data with 'time' and 'observed.'

k

An integer specifying the window size for modeling growth rates.

level

The confidence level for parameter estimates, a numeric value between 0 and 1.

disease_threshold

An integer specifying the threshold for considering a disease outbreak.

family

A character string specifying the family for modeling. Choose between "poisson," or "quasipoisson".

Value

A aedseo object containing:

  • 'reference_time': The time point for which the growth rate is estimated.

  • 'observed': The observed value in the reference time point.

  • 'growth_rate': The estimated growth rate.

  • 'lower_growth_rate': The lower bound of the growth rate's confidence interval.

  • 'upper_growth_rate': The upper bound of the growth rate's confidence interval.

  • 'growth_warning': Logical. Is the growth rate significantly higher than zero?

  • 'sum_of_cases': The sum of cases within the time window.

  • 'sum_of_cases_warning': Logical. Does the Sum of Cases exceed the disease threshold?

  • 'seasonal_onset_alarm': Logical. Is there a seasonal onset alarm?

  • 'converged': Logical. Was the IWLS judged to have converged?

Examples

# Create a tsibble object from sample data
tsd_data <- tsd(
  observed = c(100, 120, 150, 180, 220, 270),
  time = as.Date(c(
    "2023-01-01",
    "2023-01-02",
    "2023-01-03",
    "2023-01-04",
    "2023-01-05",
    "2023-01-06"
  )),
  time_interval = "day"
)

# Calculate AEDSEO with a 3-day window and a Poisson family model
aedseo_results <- aedseo(
  tsd = tsd_data,
  k = 3,
  level = 0.95,
  disease_threshold = 200,
  family = "poisson"
)

# Print the AEDSEO results
print(aedseo_results)
#> # A tibble: 4 × 10
#>   reference_time observed growth_rate lower_growth_rate upper_growth_rate
#>   <date>            <dbl>       <dbl>             <dbl>             <dbl>
#> 1 2023-01-03          150       0.204            0.0785             0.331
#> 2 2023-01-04          180       0.201            0.0874             0.316
#> 3 2023-01-05          220       0.192            0.0891             0.296
#> 4 2023-01-06          270       0.203            0.109              0.297
#> # ℹ 5 more variables: growth_warning <lgl>, sum_of_cases <dbl>,
#> #   sum_of_cases_warning <lgl>, seasonal_onset_alarm <lgl>, converged <lgl>