I am a little bit confused with your predict() method, I tried too clarify it for myself by looking into source code for it, it did not resolve my issue, so I hope you can help.
In this piece of code below, if n.ahead == 1, there is no VARX method, only VAR, is it because you assume, that the model depends only on lagged external regressors so they are not needed?
Additionaly, If you have n.ahead > 1 for VARX, there seems to no predict_all option, so what forecast step is then outputed? The last one?
Thank you!
if (n.ahead == 1) {
if (confint) {
lower <- fcst + ci[, 1]
upper <- fcst + ci[, 2]
fcst <- as.data.frame(cbind(fcst, lower, upper))
names(fcst) <- c("forecast", "lower", "upper")
}
return(fcst)
} else {
if (!VARX) {
fcst <- predictMS(matrix(fcst, nrow = 1), Y[(nrow(Y) - p + 1):nrow(Y), ], n.ahead - 1, betaPred, p, MN, predict_all = predict_all)
if (predict_all) {
row.names(fcst) <- paste0("T+", 1:n.ahead)
} else {
fcst <- t(fcst)
}
} else {
if (is.null(newxreg)) {
stop("Need new data for multi-step VARX forecasts. Re-run with new data in newxreg")
} else {
if (nrow(newxreg) < n.ahead - 1) {
stop(paste("Need at least ", n.ahead - 1, "rows of new data"))
}
C <- max(p, s)
if (contemp) {
C <- C + 3
}
fcst <- matrix(predictMSX(matrix(fcst, nrow = 1), as.matrix(Y[(nrow(Y) - C + 1):nrow(Y), 1:(k)]), n.ahead -
1, betaPred, p, newxreg, matrix(Y[(nrow(Y) - C + 1):nrow(Y), (ncol(Y) - m + 1):ncol(Y)], ncol = m), m,
s, 1, MN, contemp), ncol = 1)
}
}
}
UPD:
As of now, I have solved part of the question "... that the model depends only on lagged external regressors so they are not needed?". As I understood, it is possible to include unlagged external regressors by setting
contemp = TRUE
inside VARX list of settings in constructModel()
But now even if contemporaneous unmodeled series is included, predict() still does not ask for regressors which are corresponding to beta-0 coefficient matrix when making a 1-step-ahead forecast.
Hello, and thank you for this amaizing package!
I am a little bit confused with your predict() method, I tried too clarify it for myself by looking into source code for it, it did not resolve my issue, so I hope you can help.
In this piece of code below, if n.ahead == 1, there is no VARX method, only VAR, is it because you assume, that the model depends only on lagged external regressors so they are not needed?
Additionaly, If you have n.ahead > 1 for VARX, there seems to no predict_all option, so what forecast step is then outputed? The last one?
Thank you!
UPD: As of now, I have solved part of the question "... that the model depends only on lagged external regressors so they are not needed?". As I understood, it is possible to include unlagged external regressors by setting
inside VARX list of settings in constructModel()
But now even if contemporaneous unmodeled series is included, predict() still does not ask for regressors which are corresponding to beta-0 coefficient matrix when making a 1-step-ahead forecast.