0
$\begingroup$

I use tsCV in the forecast package to evaluate forecasts of different models over different forecasting horizons.

However, when I run the following multivariate mlp, e_mlp consists out of NA NA NA.

I would very much appreciate any help.

See below the minimal reproducible example.

library(forecast)
library(RSNNS)
xreg = as.matrix(cbind(1:120, 121:240),ncol=2)
y <- as.ts(1:120)
f <- function(xreg, y,h) {
  X <- xreg[1:length(y)]
  newX <- xreg[1:(length(y)+h)]
  fit <- mlp(y,xreg=matrix(X))
  forecast(fit, xreg=matrix(newX), h=h)
}
e_mlp <- tsCV(xreg = xreg, y= y, f, h= 15)
mse_mlp <- (colMeans(e_mlp^2, na.rm=TRUE))

when I leave out the cross-validation it works:

xreg = as.matrix(cbind(1:120, 121:240),ncol=2)
y <- as.ts(1:120)
h = 15
X <- xreg[1:length(y)]
newX <- xreg[1:(length(y)+h)]
fit <- mlp(y,xreg=matrix(X))
forecast(fit, xreg=matrix(newX), h=h)
```
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.