This function determines which Generalized Linear Model (GLM) algorithms can be applied to a dataset based on the number of weeks of data available for fitting. The function calculates the date range within the dataset and assesses whether sufficient historical data is available to apply various GLM methods.

get_possible_glm_methods(
  data,
  date_var = "date_report",
  number_of_weeks = 6,
  past_weeks_not_included = 4
)

Arguments

data

A data frame containing the data to be analyzed. This data frame should include a date variable specified by the `date_var` parameter.

date_var

A character string representing the name of the date variable in the data frame. Default is `"date_report"`.

number_of_weeks

An integer specifying the number of weeks signal detection is done. These weeks are excluded from fitting as we do a prediction for these weeks. Default is `6`.

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

A character vector of possible GLM methods that can be applied given the available data, or `NULL` if no methods are suitable given the data constraints.

The method selection criteria are: - If 4 years (208 weeks) or more of data are available: All GLM methods are possible. - If 3 to 4 years (156 to 208 weeks) of data are available: All methods except "glm farrington" and "glm farrington with timetrend" are possible. - If 2 to 3 years (104 to 156 weeks) of data are available: Only "glm mean", "glm timetrend", and "glm harmonic" are possible. - If 1 to 2 years (52 to 104 weeks) of data are available: Only the "glm mean" method is possible. - If less than 1 year (52 weeks) of data is available: No methods are possible (`NULL` is returned).

Examples

if (FALSE) {
# Example usage:
data <- data.frame(date_report = seq(as.Date("2018-01-01"), by = "week", length.out = 300))
available_methods <- get_possible_glm_methods(data)
print(available_methods)
}