whole_loo_analysis: Conduct the Entire Leave-one-Out Analysis

View source: R/cross-validation.R

whole_loo_analysisR Documentation

Conduct the Entire Leave-one-Out Analysis

Description

A wrapper around model-fitting, model-averaging, leave-one-out calculations, and error summaries for effort, catch rate, and species composition; also returns predictions and error summaries of harvest implied by the values of the other variables.

Usage

whole_loo_analysis(
  global_formulae,
  fit_data,
  var_desc = NULL,
  error_types = c("RHO", "ME", "MAE", "MPE", "MAPE"),
  ...
)

Arguments

global_formulae

Named list of with elements for effort, total_cpt, chinook_comp, chum_comp, and sockeye_comp to be passed to the formula argument of fit_global_model_one() separately.

fit_data

data.frame storing the variables for regression fitting.

var_desc

Optional character string describing the variables used in fitting. If supplied, will become the first column in the error_summary element of the output list.

error_types

A character vector specifying which types of error summaries (obtained by KuskoHarvUtils::get_errors()) to return. Options are any combination of "RHO", "RMSE", "ME", "MAE", "MPE", or "MAPE".

...

Optional arguments passed to fit_all_subsets()

Details

This function conducts several steps in a self-contained wrapper:

  1. Fits the global models to each response variable using fit_global_model_one().

  2. Fits all subsets of these global models using fit_all_subsets().

  3. Obtains model-averaged leave-one-out predictions for each record using loo_pred_model_avg().

  4. Summarizes the errors made in step 3 by response variable type and period (see KuskoHarvUtils::get_errors() and KuskoHarvUtils::get_period()).

Value

list with elements:

  • error_summary: list with elements storing data.frame objects, where each data frame stores info about the settings of the run (the values of reduce_colinearity, cwt_retain, and var_desc) and the period- and response variable-specific error summaries. Different list elements store the different error summary statistics supplied to error_types.

  • elapsed: data.frame similar to the error_summary element, except with a column for minutes elapsed.

  • loo_preds: data.frame with the model-averaged leave-one-out predictions by record and response variable.

  • models: a list with 5 elements, one each for effort, total_cpt, and chinook_comp, chum_comp, and sockeye_comp. Each element is the list of fitted lm model objects returned by fit_all_subsets().


bstaton1/KuskoHarvPred documentation built on Aug. 15, 2024, 3:30 p.m.