Description Usage Arguments Value Examples
View source: R/INTRA_FORECAST_ctree_fit.R
ctree_fit
A function to gauge the fit of a model run of an CTREE tree,
given parameters. This is a function that is used to fine-tune the CTREE tree
when forecasting
1 2 3 4 5 6 7 8 9 |
ML_data |
Dataset that has been prepared to run through CTREE. If
originally a time series object, then it has gone through the
|
minsplit |
CTREE parameter. The minimum number of observations that must exist in a node in order for a split to be attempted (default from CTREE = 20) |
mincriterion |
CTREE parameter. The value of the test-statistic
( |
minbucket |
CTREE parameter. Minimum sum of weights in a terminal node (default from CTREE = 7) |
testtype |
CTREE parameter. Which distribution to use. Options are "Bonferroni", "MonteCarlo", "Univariate" and "Teststatistic" |
teststat |
CTREE parameter. Specifies which test statistic to use when doing hypothesis testing. Options are "quad" and "max" |
nresample |
CTREE parameter. Amount of resampling to do when MonteCarlo is selected as test type (default from CTREE = 9999) |
The mean absolute prediction error (MAPE), in percentage terms, of the model run
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | ML_data <- 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")
) %>%
dplyr::filter(grouping == "state = New York & oil_company = CompanyA") %>%
tstools::transform_data_to_ts_object() %>%
decompose_ts_object_for_ML(filter_date_features = T) %>%
dplyr::mutate(col_of_interest = col_of_interest - dplyr::lag(col_of_interest)) %>%
dplyr::filter(!is.na(col_of_interest))
ctree_fit(
ML_data = ML_data,
minsplit = 20,
mincriterion = 0.975,
minbucket = 5,
testtype = "Univariate",
teststat = "quad",
nresample = 9999
)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.