Manages forecasts of one CWE.

Direct Subclasses

Private attributes

  • cwe CWE ID (default NA)

  • start_year the first year of a time period (default NA)

  • end_year the last year of a time period (default NA)

  • train the training set (default NA)

  • test the test set (default NA)

  • fcast the forecasts as a "forecast" object (default NA)

  • assessment the MAE, RMSE, MAPE and MASE in numeric form (default NA)

  • fcast_period the number of months necessary to forecast (default NA)

  • residuals_not_random the logical value indicating whether the models' residuals are not uncorrelated; cannot be used in the cases of ARFIMAModel, BaggedETSModel, StructTSModel and NNARModel for which ACF plots must be used instead (default F)

  • residuals_not_normal the logical value indicating whether the models' residuals are not normally distributed (default F)

  • bootstrap_not_used the logical value indicating whether the forecast intervals were not generated from bootstrapped residuals (default T)

  • pi_ignored the logical value; when F, then the forecast intervals can be taken seriously, otherwise the model's residuals must be checked (default F)

  • significance_level the significance level used in the Shapiro-Wilk, Ljung-Box and Breusch-Godfrey hypothesis cheking (default 0.05)

  • measures = c("MAE", "RMSE", "MAPE", "MASE") a character vector attribute used in the source code

  • tset_char = "Test set" a character attribute used in the source code (default F)

Public methods

  • new(cwe, cwe_ts, start_year, end_year, end_month) creates new NVD object

  • getStartYear() returns private attribute start_year

  • getEndYear() returns private attribute end_year

  • getTrainingSet() returns private attribute train

  • getTestSet() returns private attribute test

  • getFcasted() returns private attribute fcast

  • getMethod() returns attribute method of private attribute fcast

  • getAssessment() returns private attribute assessment

  • getFcastPeriod() returns private attribute fcast_period

  • getTSetChar() returns private attribute tset_char

  • getResiduals(model) returns residuals from model processed by zoo::na.approx; model is obtained from FitModel's method getFitted or NVDModel's method getFcasted

  • getMergedTrainTestSet() returns a stats::ts object after merging both the training set and the test set

  • getSignificanceLevel() returns private attribute significance_level

  • areResidualsNotRandom() returns private attribute residuals_not_random

  • areResidualsNotNormal() returns private attribute residuals_not_normal

  • isPiIgnored() returns private attribute pi_ignored

  • isBootstrapNotUsed() returns private attribute bootstrap_not_used

  • setSignificanceLevel(significance) sets significance as the value of private attribute significance_level

  • setResidualsNotRandom(testresult) sets testresult as the value of private attribute residuals_not_random

  • setResidualsNotNormal(testresult) sets testresult as the value of private attribute residuals_not_normal

  • setBootstrapNotUsed(logical_value) sets logical_value as the value of private attribute bootstrap_not_used

  • setPiIgnored(logical_value) sets logical_value as the value of private attribute pi_ignored

  • setFcasted(fcast_result) sets fcast_result as the value of private attribute fcast

  • setFcastPeriod(period) sets period as the value of private attribute fcast_period

  • assessModel() calculates and sets MAE, RMSE, MAPE, MASE values as the value of private attribute assessment

  • testResidualsRandomnessBox(residuals, df) uses residuals and degrees of freedom arguments and performs the Ljung-Box test; returns whether the obtained p-value is less or equal than the significance level

  • testResidualsRandomnessBreusch(residuals, df, fitted_model) uses residuals, degrees of freedom and fitted model arguments and performs the Breusch-Godfrey test; returns whether the obtained p-value is less or equal than the significance level

  • testResidualsNormality(residuals) uses residuals arguments and performs the Shapiro-Wilk test; returns whether the obtained p-value is less or equal than the significance level

  • getPlot() returns a plot of forecast results and actual values as a red line when the forecasting results are available in the private attribute fcast; adds an exclamation mark to y-axis label when self$areResidualsNotRandom() | (self$areResidualsNotNormal() & self$isBootstrapNotUsed()) | self$isPiIgnored()

  • compareCombinedAccuracy(fcast1, fcast2) takes two collections of forecasts and returns a logical value indicating whether the first collection of forecasted values has bigger amount of smaller MAE, RMSE, MAPE and MASE values than the other collection of forecasted values

  • findLambda(training_set) returns the lambda found by forecast::BoxCox.lambda based on the training set

Note

This class's private method `residuals_lag` is using GPL-3 licensed code from (R package "forecast" by Rob Hyndman, Mitchell O'Hara-Wild, Christoph Bergmeir, Slava Razbash and Earo Wang) https://github.com/robjhyndman/forecast/blob/c87f33/R/checkresiduals.R from lines 122 and 123 to calculate the lag parameter.