| NNS.ARMA.optim | R Documentation |
Wrapper function for optimizing any combination of a given seasonal.factor vector in NNS.ARMA. The objective function obj.fn on a validation window (the last length(variable) - training.set observations) is used to determine the optimum across all NNS.ARMA methods.
NNS.ARMA.optim(
variable,
h = NULL,
training.set = NULL,
seasonal.factor,
lin.only = FALSE,
negative.values = FALSE,
obj.fn = expression({
.denom <- NNS::Co.LPM(1, predicted, actual, target_x =
mean(predicted), target_y = mean(actual)) + NNS::Co.UPM(1, predicted, actual,
target_x = mean(predicted), target_y = mean(actual))
if (.denom == 0) Inf else
mean((predicted - actual)^2)/.denom
}),
objective = "min",
linear.approximation = TRUE,
ncores = NULL,
pred.int = 0.95,
print.trace = TRUE,
plot = FALSE,
bias.correction = c("none", "split")
)
variable |
a numeric vector. |
h |
integer; |
training.set |
integer; |
seasonal.factor |
integers; Multiple frequency integers considered for NNS.ARMA model, i.e. |
lin.only |
logical; |
negative.values |
logical; |
obj.fn |
expression;
The default is the mean squared error divided by the degree-1 co-movement of |
objective |
options: ("min", "max") |
linear.approximation |
logical; |
ncores |
integer; value specifying the number of cores to be used in the parallelized procedure. If NULL (default), the number of cores to be used is equal to the number of cores of the machine - 1. |
pred.int |
numeric [0, 1]; 0.95 (default) Returns the associated prediction intervals for the final estimate. Constructed from the returned model's internal validation residuals (actual - forecast), adding their LPM.VaR and UPM.VaR at |
print.trace |
logical; |
plot |
logical; |
bias.correction |
|
Returns a list containing:
$period a vector of optimal seasonal periods
$weights the optimal weights of each seasonal period between an equal weight or NULL weighting
$obj.fn the obj.fn value of the returned model's internal validation forecasts, after $bias.shift.
$method the method identifying which NNS.ARMA method was used.
$shrink whether to use the shrink parameter in NNS.ARMA.
$nns.regress whether to smooth the variable via NNS.reg before forecasting.
$bias.shift the accepted additive correction (0 when rejected or disabled). Add it to the forecast from NNS.ARMA with the returned model parameters, then apply the nonnegative support clamp if required.
$bias.validation correction policy, estimated/applied shifts, chronological estimate and acceptance rows, and raw/adjusted acceptance scores.
$raw.results forecasts before the additive bias correction.
$validation.forecast the final internal validation forecasts, including correction and support clamp.
$errors a vector of the returned model's internal validation errors (forecast - actual), before $bias.shift.
$results a vector of length h.
$lower.pred.int a vector of lower prediction intervals per forecast point.
$upper.pred.int a vector of upper prediction intervals per forecast point.
By default no bias shift is added. With bias.correction = "split" the shift is estimated on the first half of the validation window and accepted on the second. Base model selection still uses the internal validation window, so these tuning scores are not an independent evaluation of the whole forecasting procedure. Evaluate the complete procedure at fresh chronological origins.
Typically, (training.set = 0.8 * length(variable)) is used for optimization. Smaller samples could use (training.set = 0.9 * length(variable)) (or larger) in order to preserve information.
The number of combinations will grow prohibitively large, they should be kept as small as possible. seasonal.factor containing an element too large will result in an error. Please reduce the maximum seasonal.factor.
Set (ncores = 1) if routine is used within a parallel architecture.
Fred Viole, OVVO Financial Systems
Viole, F. and Nawrocki, D. (2013) "Nonlinear Nonparametric Statistics: Using Partial Moments" (ISBN: 1490523995, 2nd edition: https://ovvo-financial.github.io/NNS/book/)
## Nonlinear NNS.ARMA period optimization using 2 yearly lags on AirPassengers monthly data
## Not run:
nns.optims <- NNS.ARMA.optim(AirPassengers[1:132], training.set = 120,
seasonal.factor = seq(12, 24, 6))
## To predict out of sample using best parameters:
NNS.ARMA.optim(AirPassengers[1:132], h = 12, seasonal.factor = seq(12, 24, 6))
## Incorporate any objective function from external packages (such as \code{Metrics::mape})
NNS.ARMA.optim(AirPassengers[1:132], h = 12, seasonal.factor = seq(12, 24, 6),
obj.fn = expression(Metrics::mape(actual, predicted)), objective = "min")
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.