knitr::opts_chunk$set(
  collapse = TRUE,
  comment = "#>"
)

Setup Libraries

library(tswgewrapped)

Load Data

file = system.file("extdata", "USeconomic.csv", package = "tswgewrapped", mustWork = TRUE)
USeconomic = read.csv(file, header = TRUE, stringsAsFactors = FALSE, check.names = FALSE)
names(USeconomic) = gsub("[(|)]", "", colnames(USeconomic))
data = USeconomic

Build caret model

Since this process takes some time, I have commented this out for now and saved an already created caret model. However, feel free to uncomment this and run the model build process.

# library(caret)
# 
# # Random Parallel
# model = ModelBuildNNforCaret$new(data = data, var_interest = "logGNP", m = 2,
#                                  search = 'random',
#                                  grid = NA, tuneLength = 2,
#                                  batch_size = 132, h = 2,
#                                  parallel = TRUE,
#                                  seed = 1,
#                                  verbose = 1)
# 
# model$summarize_hyperparam_results()
# model$plot_hyperparam_results()
# 
# model$summarize_best_hyperparams()
# model$summarize_build()
# 
# caret_model = model$get_final_models(subset = 'a')

Load already saved caret model

file = system.file("extdata", "caret_model_batch_ase.rds", package = "tswgewrapped", mustWork = TRUE)
caret_model = readRDS(file)

Initialize the ModelCompareMultivariateVAR object

mdl_compare = ModelCompareNNforCaret$new(data = data, var_interest = 'logGNP',
                                         mdl_list = caret_model,
                                         verbose = 1)

Compare the models

Compare boxplot of ASE values

p = mdl_compare$plot_boxplot_ases()

Statistically Compare the models

mdl_compare$statistical_compare()  

Simple Forecasts (with various options)

This is not currently supported since it needs future values to be passed and we dont have these values yet (unless we forecast them). We will add this functionality in the future.

# p = mdl_compare$plot_simple_forecasts()

Plot and compare the forecasts per batch

p = mdl_compare$plot_batch_forecasts()

Plot and compare the ASEs per batch

p = mdl_compare$plot_batch_ases() 

Raw Data and Metrics

ASEs = mdl_compare$get_tabular_metrics(ases = TRUE)
print(ASEs)
forecasts = mdl_compare$get_tabular_metrics(ases = FALSE)
print(forecasts)


josephsdavid/tswgewrapped documentation built on July 31, 2020, 9:36 a.m.