fit_aarr_model: Generate prediction from model object

View source: R/predict_aarr.R

fit_aarr_modelR Documentation

Generate prediction from model object

Description

fit_aarr_data() calculates AARR and then generates a prediction based on calculated AARR.

Usage

fit_aarr_model(
  df,
  response,
  interpolate,
  test_col,
  sort_col,
  sort_descending,
  sort_col_min,
  group_col,
  group_models,
  obs_filter,
  pred_col
)

Arguments

df

Data frame of model data.

response

Column name of prevalence variable to be used to calculate AARR.

interpolate

Logical value, whether or not to interpolate values based on estimated AARR between observations. Defaults to FALSE.

test_col

Name of logical column specifying which response values to remove for testing the model's predictive accuracy. If NULL, ignored. See model_error() for details on the methods and metrics returned.

sort_col

Column name of column to arrange data by in dplyr::arrange(), prior to filtering for latest contiguous time series and producing the forecast. Not used if NULL, defaults to "year".

sort_descending

Logical value on whether the sorted values from sort_col should be sorted in descending order. Defaults to FALSE.

sort_col_min

If provided, a numeric value that sets a minimum value needed to be met in the sort_col for an observation to be used in calculating AARR. If sort_col = "year" and sort_col_min = 2008, then only observations from 2008 onward will be used in calculating AARR.

group_col

Column name(s) of group(s) to use in dplyr::group_by() when supplying type, calculating mean absolute scaled error on data involving time series, and if group_models, then fitting and predicting models too. If NULL, not used. Defaults to "iso3".

group_models

Logical, if TRUE, fits and predicts models individually onto each group_col. If FALSE, a general model is fit across the entire data frame.

obs_filter

String value of the form "⁠logical operator⁠ integer" that specifies the number of observations required to fit the model and replace observations with predicted values. This is done in conjunction with group_col. So, if group_col = "iso3" and obs_filter = ">= 5", then for this model, predictions will only be used for iso3 vales that have 5 or more observations. Possible logical operators to use are >, >=, <, <=, ==, and !=.

If `group_models = FALSE`, then `obs_filter` is only used to determine when
predicted values replace observed values but **is not** used to restrict values
from being used in model fitting. If `group_models = TRUE`, then a model
is only fit for a group if they meet the `obs_filter` requirements. This provides
speed benefits, particularly when running INLA time series using `predict_inla()`.
pred_col

Column name to store predicted value.

Value

A data frame.


caldwellst/augury documentation built on Oct. 10, 2024, 8:20 a.m.