Description Usage Arguments Value Examples
View source: R/HELPER_create_combined_fc_errors_table.R
create_combined_fc_errors_table
is a function to create a tibble, that
has the same structure as the fc_errors table. It is formed by combining two
groups via one of the four basic operators.
1 2 3 4 5 6 7 8 9 10 | create_combined_fc_errors_table(
first_main_forecasting_table,
second_main_forecasting_table,
first_fc_model = "",
second_fc_model = "",
new_fc_model = "",
operator = c("addition", "subtraction", "division", "multiplication"),
group_variable = "",
new_group_name = ""
)
|
first_main_forecasting_table |
A tibble containing a single row and
several columns of data required for time series forecasting, which has
been created using the |
second_main_forecasting_table |
A tibble containing a single row and
several columns of data required for time series forecasting, which has
been created using the |
first_fc_model |
A character specifying which forecast model to filter from first_main_forecasting_table. Only one specified forecast model may be selected! |
second_fc_model |
A character specifying which forecast model to filter from second_main_forecasting_table. Only one specified forecast model may be selected! |
new_fc_model |
The name for the fc_model column in the new fc_error table. |
operator |
A character that specifies what operation you want to take place between the two values. It can be either "addition", "subtraction", "multiplication" or "division". |
group_variable |
The name of the grouping column where the two main_forecasting_tables differ |
new_group_name |
The name of the new group you have created! |
A tibble object, structured almost identical to a typical fc_errors table. The difference is that this object also has the historical actuals data
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 27 28 29 30 31 | main_forecasting_table <- dummy_gasprice %>%
tstools::initialize_ts_forecast_data(
date_col = "year_month",
col_of_interest = "gasprice",
group_cols = c("state", "oil_company")
) %>%
dplyr::filter(period >= as.Date("2004-01-31")) %>%
dplyr::filter(grouping %in% c(
"state = New York & oil_company = CompanyB",
"state = New York & oil_company = CompanyA"
)) %>%
create_main_forecasting_table() %>%
add_fc_models_to_main_forecasting_table(
fc_methods = c("basic", "linear", "prophet")
)
first_main_forecasting_table <- main_forecasting_table %>%
dplyr::filter(ts_split_date == 200512) %>%
dplyr::filter(grouping == "state = New York & oil_company = CompanyB")
second_main_forecasting_table <- main_forecasting_table %>%
dplyr::filter(ts_split_date == 200512) %>%
dplyr::filter(grouping == "state = New York & oil_company = CompanyA")
create_combined_fc_errors_table(
first_main_forecasting_table = first_main_forecasting_table,
second_main_forecasting_table = second_main_forecasting_table,
first_fc_model = "fc_linear_trend",
second_fc_model = "fc_prophet_050cps",
new_fc_model = "fc_division",
operator = "division",
group_variable = "oil_company",
new_group_name = "Company-B over CompanyA"
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.