plot_xreg: Create plot to compare select external regressors to variable...

Description Usage Arguments Value Examples

View source: R/VISUALIZE_plot_xreg.R

Description

plot_xreg is a function to create a plot which compares selected external regressors with the variable of interest

Usage

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

xreg

A vector that contains strings with the names of the external regressors to be plotted.

Value

A plotly object displaying multiple plots.

Examples

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

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