View source: R/predict_forecast_avg_trend.R
fit_forecast_average_model | R Documentation |
Used within predict_forecast_avg_trend()
, this function fits the model to the data
frame, working whether the model is being fit across the entire data frame or
being fit to each group individually. Data is filtered prior to fitting,
model(s) are fit, and then fitted values are generated on the original.
fit_forecast_average_model(
df,
forecast_function,
response,
average_cols,
weight_col,
...,
test_col,
group_col,
group_models,
sort_col,
sort_descending,
pred_col,
pred_upper_col,
pred_lower_col,
filter_na,
ret
)
df |
Data frame of model data. |
forecast_function |
An R function that outputs a forecast object coming from the
forecast package. You can directly pass |
response |
Column name of response variable to be used as the input to the forecast function. |
average_cols |
Column name(s) of column(s) for use in grouping data for averaging, such as regions. If missing, uses global average of the data for infilling. |
weight_col |
Column name of column of weights to be used in averaging, such as country population. |
... |
Additional arguments passed to the forecast function. |
test_col |
Name of logical column specifying which response values to remove
for testing the model's predictive accuracy. If |
group_col |
Column name(s) of group(s) to use in |
group_models |
Logical, if |
sort_col |
Column name of column to arrange data by in |
sort_descending |
Logical value on whether the sorted values from |
pred_col |
Column name to store predicted value. |
pred_upper_col |
Column name to store upper bound of confidence interval
generated by the |
pred_lower_col |
Column name to store lower bound of confidence interval
generated by the |
filter_na |
Character value specifying how, if at all, to filter |
ret |
Character vector specifying what values the function returns. Defaults to returning a data frame, but can return a vector of model error, the model itself or a list with all 3 as components. |
If fitting models individually to each group, mdl
will never be returned, as
as these are instead a large group of models. Otherwise, a list of mdl
and df
is returned and used within predict_forecast()
.
List of mdl
(fitted model) and df
(data frame with fitted values
and confidence bounds generated from the model).
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.