I want to evaluate the out-of-sample one-step-ahead performance of a nnetar time series forecasting model in R. I'm looking for something analogous to the following code, but using nnetar.
#prepare train and test set
train <- lynx[1:100]
test <- lynx[101:length(lynx)]
# fitting out of sample
train.fit <- auto.arima(train)
plot(forecast(train.fit, h = 20))
test.fit <- Arima(test, model = train.fit)
one.step <- fitted(test.fit)
The following attempt with nnetar doesn't raise any errors, but the one.step result has 8 NAs.
fit <- nnetar(train)
plot(forecast(fit, h = 20))
fit2 <- nnetar(test, model = fit)
one.step <- fitted(fit2)
I don't even get that far with my real data which holds 700 training points of 5 day frequency weekday-only data. The test.series holds 28 days.
fit <- nnetar(train.series)
fit2 <- nnetar(test.series, model = fit)
On the fit2 line above, I get the error:
Error in nnet.default(x = c(0.223628229573182, -0.783157335744087, -0.560497369997497, :
weights vector of incorrect length
In addition: Warning message:
In nnetar(test.series, model = fit) :
Reducing number of lagged inputs due to short series
Any help/examples would be appreciated.