How and why did I got the error with forecast.mlp with xreg?

48 Views Asked by At

I am fitting a neural network time series model with exogenous variables using mlp() function with its xreg parameter in nnfor library using the departure data in fpp2 library.

Here is my code:

data("departures",package = "fpp2")
z = cbind(departures[,2:3]) %>% as.matrix()
set.seed(38912)
fit_mlp_xreg2 <- mlp(departures[,1],hd = c(5,2),
    xreg = z,
    reps = 1) 
forecast(object = fit_mlp_xreg1,xreg = z) 

Here's what I got:

Error in forecast.net(object, h = h, y = y, xreg = xreg, ...) : Length of xreg must be longer that y + forecast horizon.

Can you tell me the true source of the error and how do I fix this?

0

There are 0 best solutions below