get_ensemble_fit_and_predictions: Calculate ensemble fits for a single window size

View source: R/qra_fit_convenience.R

get_ensemble_fit_and_predictionsR Documentation

Calculate ensemble fits for a single window size

Description

Calculate ensemble fits for a single window size

Usage

get_ensemble_fit_and_predictions(
  forecasts,
  observed_by_location_target_end_date,
  forecast_week_end_date,
  window_size,
  intercept = FALSE,
  combine_method = c("ew", "convex", "positive", "unconstrained", "median",
    "convex_median", "rel_wis_weighted_median", "rel_wis_weighted_mean",
    "mean_weights_weighted_median"),
  quantile_groups = NULL,
  noncross = "constrain",
  missingness = c("by_location_group", "rescale", "mean_impute"),
  impute_method = "mean",
  backend = "quantmod",
  check_missingness_by_target = FALSE,
  do_q10_check,
  do_nondecreasing_quantile_check,
  do_baseline_check,
  do_sd_check,
  sd_check_table_path = NULL,
  sd_check_plot_path = NULL,
  baseline_tol = 1.2,
  max_weight = NULL,
  top_models = 0,
  manual_eligibility_adjust,
  return_eligibility = TRUE,
  return_all = FALSE,
  partial_save_frequency,
  partial_save_filename
)

Arguments

forecasts

data frame with columns 'model', 'location', 'forecast_week_end_date', 'target', 'quantile', and 'value'

observed_by_location_target_end_date

data frame with columns 'location', 'base_target', 'target_end_date', and 'observed'

forecast_week_end_date

Date object: date of the saturday for the end of the forecast week; week-ahead targets are with respect to this date

window_size

size of window

intercept

logical specifying whether an intercept is included

combine_method

character specifying the approach to model combination: "equal", "convex", "positive", "unconstrained", "median", or "convex_median". The first four form a linear combination of quantiles across component models with varying levels of restrictions on the combination coefficients. "median" takes the median across models at each quantile level, and "convex_median" uses a weighted median with convext constraints on weights

quantile_groups

Vector of group labels for quantiles, having the same length as the number of quantiles. Common labels indicate that the ensemble weights for the corresponding quantile levels should be tied together. Default is rep(1,length(quantiles)), which means that a common set of ensemble weights should be used across all levels. This is the argument tau_groups for quantmod::quantile_ensemble, and may only be supplied if ⁠backend = 'quantmod⁠

noncross

string specifying approach to handling quantile noncrossing: one of "constrain" or "sort". "constrain" means estimation is done subject to constraints ruling out quantile crossing. "sort" means no such constraints are imposed during estimation, but the resulting forecasts are sorted.

missingness

character specifying approach to handling missing forecasts: 'by_location_group', 'rescale', and 'impute'

impute_method

character string specifying method for imputing missing forecasts; either 'mean' for mean imputation or 'none' for no imputation

backend

back end used for optimization.

check_missingness_by_target

if TRUE, record missingness for every combination of model, location, forecast week, and target; if FALSE, record missingness only for each model and location

do_q10_check

if TRUE, do q10 check

do_nondecreasing_quantile_check

if TRUE, do nondecreasing quantile check

max_weight

numeric value for maximum weight. Ignored unless qra_model is rel_wis_weighted_median or rel_wis_weighted mean and backend is grid_search

manual_eligibility_adjust

character vector of model abbreviations for models eliminated based on visual inspection

return_eligibility

if TRUE, return model eligibility

return_all

if TRUE, return model fits

Value

tibble or data frame with ensemble fits and results


reichlab/covidEnsembles documentation built on Jan. 31, 2024, 7:21 p.m.