This function performs automated an early detection of disease outbreaks, (aeddo), on a time series data set. It utilizes hierarchical models in an innovative manner to infer one-step ahead random effects. In turn, these random effects are used directly to characterize an outbreak.
Arguments
- data
A tibble containing the time series data, including columns 'y' for observed values,'n' for population size, and other covariates of interest.
- formula
A model formula for the fixed effects in the hierarchical model to fit to the data.
- k
An integer specifying the rolling window size employed for parameter estimation.
- sig_level
The quantile from the random effects distribution used for defining the for outbreak detection threshold, a numeric value between 0 and 1.
- exclude_past_outbreaks
logical value indicating whether past outbreak related observations should be excluded from future parameter estimation.
- init_theta
Initial values for model parameters in optimization.
- lower
Lower bounds for optimization parameters.
- upper
Upper bounds for optimization parameters.
- method
The optimization method to use, either "BFGS" (default) or "L-BFGS-B".
Value
A tibble-like 'aedseo' object containing:
'window_data': A list of tibble, each representing the data for this windowed parameter estimation.
'reference_data': A list of tibble, each representing the data for the reference time point.
'phi': The dispersion parameter.
'lambda': The estimated outbreak intensity.
'u': The one-step ahead random effect.
'u_probability': The probability of observing the one-step ahead random effect.
'outbreak_alarm': Logical. Indicates if an outbreak is detected.
Examples
# Create an example aedseo_tsd object
aeddo_data <- data.frame(
time = as.Date(c(
"2023-01-01",
"2023-01-02",
"2023-01-03",
"2023-01-04",
"2023-01-05",
"2023-01-06"
)),
y = c(100, 120, 180, 110, 130, 140),
n = 1
)
# Supply a model formula
fixed_effects_formula <- y ~ 1
# Choose a size for the rolling window
k <- 2
# ... and quantile for the threshold
sig_level <- 0.9
# Employ the algorithm
aeddo_results <- aeddo(
data = aeddo_data,
formula = fixed_effects_formula,
k = k,
sig_level = sig_level,
exclude_past_outbreaks = TRUE,
init_theta = c(1, 0),
lower = c(-Inf, 1e-6),
upper = c(Inf, 1e2),
method = "L-BFGS-B"
)
# Print the results
print(aeddo_results)
#> # A tibble: 4 × 7
#> window_data reference_data phi lambda u u_probability outbreak_alarm
#> <list> <list> <dbl> <dbl> <dbl> <dbl> <lgl>
#> 1 <df [2 × 3]> <df [1 × 3]> 0.000001 110. 1.00 0.528 FALSE
#> 2 <df [2 × 3]> <df [1 × 3]> 0.0339 150. 0.777 0.105 FALSE
#> 3 <df [2 × 3]> <df [1 × 3]> 0.0525 145. 0.909 0.369 FALSE
#> 4 <df [2 × 3]> <df [1 × 3]> 0.000001 120. 1.00 0.508 FALSE