plot_xreg_drivers: Create plot to see how selected external regressor influences...

Description Usage Arguments Value Examples

View source: R/VISUALIZE_plot_xreg_drivers.R

Description

plot_xreg_driver is a function to create a plot which shows how one external regressor influences the variable of interest, ceteris paribus

Usage

1
2
3
4
5
6
plot_xreg_drivers(
  main_forecasting_table,
  xreg = "",
  delta = 0,
  granularity = 50
)

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, otherwise the function does not run.

xreg

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

delta

A numeric to look at how many deltas one wants for xreg. Applicable only in ML fc_models (e.g. trees and forests) where such deltas are taken into account when running a forecast.

granularity

A numeric determining how fine one wants the plot to be. Higher numbers return better resolution plots, but will also increase run time.

Value

A plotly object displaying how the selected xreg drivers the variable of interest.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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) %>%
   add_fc_models_to_main_forecasting_table(
      periods_ahead = 12
   ) %>%
   dplyr::filter(grouping == "state = New York   &   oil_company = CompanyA") %>%
   plot_xreg_drivers(
      xreg = "spotprice"
   )

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