nnetar(x, p, P=1, size, repeats=20, lambda=NULL)
## S3 method for class 'nnetar':
forecast(object, h=ifelse(object$m > 1, 2 * object$m, 10),
lambda=object$lambda, ...)
nnetar
generated by nnetar
.nnetar
returns an object of class "nnetar
".
An object of class "forecast
".The function summary
is used to obtain and print a summary of the
results, while the function plot
produces a plot of the forecasts and prediction intervals.
The generic accessor functions fitted.values
and residuals
extract useful features of the value returned by nnetar
.
An object of class "forecast"
is a list containing at least the following elements:
object
itself or the time series used to create the model stored as object
).x
as inputs and a single hidden layer with size
nodes. The inputs are for lags 1 to p
, and lags m
to mP
where m=frequency(x)
. A total of repeats
networks are fitted, each with random starting weights. These are then averaged when computing forecasts. The network is trained for one-step forecasting. Multi-step forecasts are computed recursively. The fitted model is called an NNAR(p,P) model and is analogous to an ARIMA(p,0,0)(P,0,0) model but with nonlinear functions.The function calls the avNNet
function from the caret
package to train the networks.
fit <- nnetar(lynx)
fcast <- forecast(fit)
plot(fcast)
Run the code above in your browser using DataLab