Use mean error to correct predictions
Usage
error_correct_fn(
df,
response,
group_col,
sort_col,
sort_descending,
pred_col,
pred_upper_col,
pred_lower_col,
test_col,
error_correct,
error_correct_cols,
shift_trend
)Arguments
- df
Data frame of model data.
- response
Column name of response variable.
- 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 ifgroup_models, then fitting and predicting models too. IfNULL, not used. Defaults to"iso3".- sort_col
Column name(s) to use to
dplyr::arrange()the data prior to supplying type and calculating mean absolute scaled error on data involving time series. IfNULL, not used. Defaults to"year".- sort_descending
Logical value on whether the sorted values from
sort_colshould be sorted in descending order. Defaults toFALSE.- pred_col
Column name to store predicted value.
- pred_upper_col
Column name to store upper bound of confidence interval generated by the
predict_...function. This stores the full set of generated values for the upper bound.- pred_lower_col
Column name to store lower bound of confidence interval generated by the
predict_...function. This stores the full set of generated values for the lower bound.- test_col
Name of logical column specifying which response values to remove for testing the model's predictive accuracy. If
NULL, ignored. Seemodel_error()for details on the methods and metrics returned.- error_correct
Logical value indicating whether or not whether mean error should be used to adjust predicted values. If
TRUE, the mean error between observed and predicted data points will be used to adjust predictions. Iferror_correct_colsis notNULL, mean error will be used within those groups instead of overall mean error.- error_correct_cols
Column names of data frame to group by when applying error correction to the predicted values.
- shift_trend
Logical value specifying whether or not to shift predictions so that the trend matches up to the last observation. If
error_correctandshift_trendare bothTRUE,shift_trendtakes precedence.
Value
Depending on the value passed to ret, either a data frame with
predicted data, a vector of errors from model_error(), a fitted model, or a list with all 3.
