get_fitted_forecast_values: Get fitted values of the "forecast" forecast models, post...

Description Usage Arguments Value Examples

View source: R/POST_FORECAST_get_fitted_forecast_values.R

Description

get_fitted_forecast_values is a function that creates fitted values from the forecast models in the R package "forecast". The fitted values vary with respect to one changing external regressor.

Usage

1
get_fitted_forecast_values(main_forecasting_table, main_fit_table, xreg = "")

Arguments

main_forecasting_table

A tibble containing a single row per group and several columns of data required for time series forecasting, which has been created using the create_main_forecasting_table function and which has been extended with the fc_models and fc_errors columns using the add_fc_models_to_main_forecasting_table function. Note that this table should have the output of a multivariate analysis.

main_fit_table

A tibble containing information about the specific fc_model and external regressor values to be used as inputs

xreg

A character that contains a string with the name of the external regressor to be plotted.

Value

A vector of fitted values

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
main_forecasting_table <- tstools::initialize_ts_forecast_data(
      data = dummy_gasprice,
      date_col = "year_month",
      col_of_interest = "gasprice",
      group_cols = c("state", "oil_company"),
      xreg_cols = c("spotprice", "gemprice")
   ) %>%
   create_main_forecasting_table() %>%
   dplyr::filter(ts_split_date == 200503) %>%
   dplyr::filter(grouping == "state = New York   &   oil_company = CompanyA") %>%
   add_fc_models_to_main_forecasting_table(
      periods_ahead = 12,
      fc_methods = c("arima", "linear", "nn"),
      keep_fc_model_objects = T
   )
fc_models <- names(main_forecasting_table$fc_models[[1]])
main_fit_table <- tibble::tibble(
   xreg_value = vector(length = 100 * length(fc_models)),
   fitted = vector(length = 100 * length(fc_models)),
   fc_model = rep(fc_models, each = 100)
)
get_fitted_forecast_values(
   main_forecasting_table = main_forecasting_table,
   main_fit_table = main_fit_table,
   xreg = "spotprice"
)

ing-bank/tsforecast documentation built on Sept. 18, 2020, 9:40 a.m.