I’m still encountering the same issue when combining tscv with nnetar (with h = 2 and additional input variables). The forecast errors for both horizons (h = 1 and h = 2) terminate two observations before the end of the sample.
In contrast, when using ARMA with tscv, the horizon alignment behaves as expected:
• for 1-step-ahead forecasts, errors end 1 observation before the final data point
• for 2-step-ahead forecasts, errors end 2 observations before the final data point.
This raises the question of whether the behavior I’m seeing with nnetar + tscv is a known issue or a specification problem on my end.
Could you please advise on how to address this? Is shifting the nnetar forecast errors down by two steps a reasonable solution, or is there a more appropriate way to handle this alignment issue when using tscv with nnetar?
This is my code:
fit <- function(x, h, xreg, newxreg) {
forecast(nnetar(x, xreg=xreg, p=1, size=5, repeats=5), xreg=newxreg, h=h)
}
xreg_data <- data.frame(cons)
error <- data.frame(forecast::tsCV(price, fit, h=2,
window = 365, initial =1, xreg=xreg_data))