Get signals based on a weigthed GLM quasipoisson regression model for the expected case counts The GLM is flexible being able to just fit a mean, add a time trend, fit a harmonic sin/cos model or the seasons from the farringtonflexible.

get_signals_glm(
  data_aggregated,
  number_of_weeks = 6,
  model = "mean",
  time_trend = TRUE,
  return_full_model = TRUE,
  alpha_upper = 0.05,
  intervention_date = NULL,
  min_timepoints_baseline = 12,
  min_timepoints_trend = 12,
  past_weeks_not_included = 4
)

Arguments

data_aggregated

data.frame, aggregated data with case counts.

number_of_weeks

integer, specifying number of weeks to generate signals for.

model

character, default "mean" one of c("mean", "sincos", "FN") specifying which kind of model the glm is fitting. "mean" fits an intercept model, "sincos" a harmonic sincos model, "FN" uses the seasgroups from farrington to fit parameters for seasonality.

time_trend

boolean, default TRUE, when TRUE a timetrend is fitted in the glm describing the expected number of cases.

return_full_model

boolean, default TRUE, specifying whether the fitted values of the model obtained from fitting the model to the first week of number_of_weeks should be returned and attached to data_aggregated as well.

alpha_upper

decimal between 0 and 1, default 0.05 specifying the pvalue cutoff used for computing the threshold, when set to 0.05 the 95 percent quantile is used.

intervention_date

A date object or character of format yyyy-mm-dd or NULL specifying the date for the intervention in the pandemic correction models. Default is NULL which indicates that no intervention is done, i.e. no additional intercept and possibly new time trend is fitted. When a date is given a new intercept and possibly time_trend (if time_trend == TRUE) is fitted.

min_timepoints_baseline

integer, default 12, this parameter is only used when intervention_date is not NULL, specifying the number of weeks at least needed for fitting a new baseline after the intervention.

min_timepoints_trend

integer, default 12, this parameter is only used when intervention_date is not NULL, specifying the number of weeks at least needed for fitting a new timetrend after the intervention.

past_weeks_not_included

An integer specifying the number of past weeks to exclude from the fitting process. This can be useful for excluding recent data with outbreaks or data that may not be fully reported. Default is `4`.

Value

data.frame aggregated data with case counts and additional columns alarms, upperbound and expected obtained from the signal detection algorithm. If return_full_model == TRUE then expected_pad is also added as a column to data_aggregated.

Examples

if (FALSE) {
data_aggregated <- input_example %>%
  preprocess_data() %>%
  aggregate_data() %>%
  add_rows_missing_dates()
results <- get_signals_glm(data_aggregated)
}