Page 1 of 2
recursive vs. direct multi-step ahead forecasting
Posted: Fri Mar 26, 2021 5:55 am
by ac_1
Hi Tom,
Is there a "vanilla" example of recursive vs. direct multi-step ahead forecasting in RATS?
Cheers,
Amarjit
Re: recursive vs. direct multi-step ahead forecasting
Posted: Sun Mar 28, 2021 5:03 am
by ac_1
To be more precise: it is straightforward to generate forecasts in rolling regressions. Let's say I have an AR(5) model and I want to generate h=1, h=2, h=3, ..., h=20 steps ahead. At each iteration within the loop I can do so dynamically from the AR(5) using the previous forecasts. I want to compare these iterated forecasts with those from a direct forecasting scheme. From my understanding of direct forecasts, I will require 20 different models, one for each h-step, to forecast h=1, h=2, h=3, ..., h=20 steps ahead, at each iteration within the loop. How do I generate the direct forecasts for comparison with the iterated?
Re: recursive vs. direct multi-step ahead forecasting
Posted: Wed Mar 31, 2021 6:45 pm
by TomDoan
Direct multi-step forecasting, if I understand what you mean, involves running a regression of X(t) on X(t-h),X(t-(h+1),...) and using that to forecast X(t+h|t). That can only be used for that one specific horizon, so you would have to estimate a different model for different step numbers. It's basically the same idea as
Jorda's local projections.
Re: recursive vs. direct multi-step ahead forecasting
Posted: Sat Apr 03, 2021 1:41 pm
by ac_1
TomDoan wrote: if I understand what you mean, involves running a regression of X(t) on X(t-h),X(t-(h+1),...) and using that to forecast X(t+h|t).
Yes, from the general relationship:
h=1: X(t) = beta0 + beta1*X(t-1) + beta2*X(t)
forecast eqn 1: X(t+1) = beta0 + beta1*X(t-1) + beta2*X(t)
h=2: X(t) = beta0 + beta1*X(t-2) + beta2*X(t-1) + beta3*X(t)
forecast eqn 2: X(t+2) = beta0 + beta1*X(t-2) + beta2*X(t-1) + beta3*X(t)
etc
h=20: X(t) = beta0 + beta1*X(t-20) + beta2*X(t-19) + ... + beta21*X(t)
forecast eqn 20: X(t+20) = beta0 + beta1*X(t-20) + beta2*X(t-19) + ... + beta21*X(t)
Now, push each forecast eqn back by 1 to get all RHS terms lagged, except for beta0
h=1 forecast eqn 1: X(t) = beta0 + beta1*X(t-2) + beta2*X(t-1)
h=2 forecast eqn 2: X(t+1) = beta0 + beta1*X(t-3) + beta2*X(t-2) + beta3*X(t-1)
etc
h=20 forecast eqn 20: X(t+19) = beta0 + beta1*X(t-21) + beta2*X(t-20) + ... + beta21*X(t-1)
But if X is 1 variable these eqn's will not be a fair comparison vs. an AR(5).
I think for each forecast eqn there should be beta0 and a maximum of only 5 lagged terms on the RHS, the beta1's to beta5's. Right?
Re: recursive vs. direct multi-step ahead forecasting
Posted: Sat Apr 03, 2021 2:22 pm
by TomDoan
Theoretically, if the true representation is an AR(5), then each dynamic forecast, no matter how many steps, requires just the last five observed historical values, and the coefficients on those are specific non-linear functions of the original AR(5) coefficients. Of course, in practice the AR(5) coefficients aren't known with certainty. The idea behind direct forecasting is to estimate the weights on those lags directly. Whether that works better is not clear---one major disadvantage is that the multi-step prediction errors are (highly) serially correlated which affects the ability to estimate the coefficients.
Re: recursive vs. direct multi-step ahead forecasting
Posted: Thu Jul 08, 2021 6:04 am
by ac_1
Thanks.
I can generate Direct multi-step ahead forecasts, requiring just the last two observed historical values, for an AR(2) (for simplicity) as follows:
Code: Select all
* Direct multi-step Forecasts (inclusive of 1-step ahead Direct Forecast, which is the same as 1-step ahead static/"Iterated" Forecast)
clear fd
do jj = 0, 11
linreg(define=eq,noprint) y start end
# constant y{1+jj to 2+jj}
set fd end+1+jj end+1+jj = %beta(1) + %beta(2)*y(end) + %beta(3)*y(end-1)
end do
print end+1 end+12 fd
I think they are correct?
From the Technical Information in
https://estima.com/ratshelp/index.html? ... ction.html calculation of multi-step ahead (static & Iterated) standard errors of forecasts as in-built in FORECAST or UFORECAST instructions is not so straightforward.
How do I calculate the standard errors of Direct multi-step ahead forecasts, for specifications with LINREG and BOXJENK?
Re: recursive vs. direct multi-step ahead forecasting
Posted: Mon Jul 12, 2021 12:40 pm
by TomDoan
You can use PRJ to get both the forecasts and the component of the forecast variance that is due to coefficient uncertainty:
do jj=0,11
linreg(lags=jj-1,lwindow=newey) y start end
# constant y{jj+1 jj+2}
prj(xvx=varFromBeta) yhat end+jj+1 end+jj+1
end do jj
(You can't use the STDERRS option on the PRJ because that assumes the whole model is estimated with homoscedastic errors). That does not include the error from the model itself (if the coefficients were known). I believe the variance of that can be estimated using the %SIGMASQ of the last regression. (The residuals are potentially highly serially correlated, but their variance is an estimate of the multi-step projection variance).
I think you will find that the whole idea isn't really very good. The Jorda calculations are looking at the effects of isolated known shocks, while forecasts depend upon an accumulation of a lot of those.
Re: recursive vs. direct multi-step ahead forecasting
Posted: Tue Jul 13, 2021 7:36 am
by ac_1
Thanks.
I am not certain of the exact formula for the standard error of forecast for Direct Forecasts, however from equation (2), Technical Information,
https://estima.com/ratshelp/index.html? ... ction.html, which is the equation variance + the estimation variance; square-rooting:
set SEF end+1 end+12 = sqrt( %SIGMASQ + (%SIGMASQ * varFromBeta))
Correct?
SEF are 'marginally' larger and do not get wider with forecast horizon (presumably as a particular regression equation has been directly used to make the multiperiod ahead forecast) than those in comparison with Iterated Forecasts.
Re: recursive vs. direct multi-step ahead forecasting
Posted: Tue Jul 13, 2021 11:27 am
by TomDoan
No.
1. The varFromBeta is the variance itself (since the beta variances are estimated with HAC) ---you don't scale it by anything.
2. Each regression has a different %SIGMASQ so you need to compute those inside your horizon loop.
They should be getting wider because the variances on the coefficients increase (though not necessarily uniformly) with the horizon, and the error variance should also be getting larger (again, not necessarily uniformly). However, don't overinterpret your results. These (and the ones from the simple AR) are estimates only, and, in particular, the HAC variances may have a considerable error because of the amount of serial correlation in the residuals.
Re: recursive vs. direct multi-step ahead forecasting
Posted: Wed Jul 14, 2021 2:06 am
by ac_1
I now have the following:
do jj=1,12
linreg(lags=jj,lwindow=newey,print) y start end
# constant y{jj jj+1}
prj(xvx=varFromBeta) yhat end+jj end+jj
set SEF end+jj end+jj = sqrt(%SIGMASQ + varFromBeta)
end do jj
print end+1 end+12 SEF
I am not certain this is correct?
As I think the Direct one-step ahead forecast SE should be the same as the Iterated one-step ahead forecast SE, but it is not (as the one-step ahead Direct Forecast is exactly the same as the one-step ahead Iterated Forecast, as it should be).
However now the SEF's widen, not necessarily uniformly, and are more similar in size to the Iterated forecast SE's.
Re: recursive vs. direct multi-step ahead forecasting
Posted: Wed Jul 14, 2021 8:28 am
by TomDoan
No; that's correct. This uses HAC variances for the one-step model (and uses %SIGMASQ rather than the degree of freedom corrected version).
Re: recursive vs. direct multi-step ahead forecasting
Posted: Thu Jul 15, 2021 1:44 am
by ac_1
Here's a version using BOXJENK:
do jj=1,12
boxjenk(constant,ar=||jj,jj+1||,derives=dd) y1 start end resids_y1
*
* Eicker-White SE's
*
mcov / resids_y1
# dd
compute xxrobust=%xx*%cmom*%xx
do i = 1, %nreg
comp tStat = %beta(i)/xxrobust(i,i)**0.5
comp pValue = %ttest(-abs(tStat),%ndf)
disp "tStat " # i #.######### tStat "pValue" # i #.######### pValue
end do i
*
prj(xvx=varFromBeta1) yhat1 end+jj end+jj
set SEF1 end+jj end+jj = sqrt( %SIGMASQ + (%SIGMASQ * varFromBeta1))
end do jj
The Direct Forecasts are almost identical to LINREG. BOXJENK does not have a HAC estimator, Eicker-White's have been calculated manually, therefore the scaling factor has been included in SEF1, else SEF1's are just smaller than those from SEF.
Re: recursive vs. direct multi-step ahead forecasting
Posted: Thu Jul 15, 2021 8:13 am
by TomDoan
I'm not sure why you are even bothering doing this with the BOXJENK. An AR model done with BOXJENK should be (in effect) identical to an AR model done with LINREG. And an ARMA model doesn't have an equivalent "direct" model. (The whole design of ARMA models depends upon the residuals being serially uncorrelated---direct forecasting intentionally produces serially correlated residuals).
Re: recursive vs. direct multi-step ahead forecasting
Posted: Fri Jul 16, 2021 4:45 am
by ac_1
TomDoan wrote: An AR model done with BOXJENK should be (in effect) identical to an AR model done with LINREG.
Yes.
TomDoan wrote:And an ARMA model doesn't have an equivalent "direct" model.
I was not aware of that.
Returning to the LINREG calculations but now with the dependent variable being the DIFFERENCE of y i.e dy.
Aim: I want to plot PI's of the LEVELS.
Thus,
to back-out the LEVELS I have accumulated yhat, the DIFFERENCES, and added to the LEVEL of y at y(end) to get 'fcst_DF'.
I have squared SEF and accumulated to get 'acc_SEFSQ_DF' (variances are additive standard deviations are not).
Therefore, a typical PI calculation for the LEVELS is:
set lower95_DF iend+1 iend+13 = fcst_DF+%invnormal(.025)*sqrt(acc_SEFSQ_DF)
I have tried the DIRECT FORECAST technique on the one series 'dy' and the fan chart for the LEVELS widens, as expected, but is slightly narrower compared to the fan chart from ITERATED FORECASTS.
Does the above appear reasonable?
Re: recursive vs. direct multi-step ahead forecasting
Posted: Fri Jul 16, 2021 12:30 pm
by TomDoan
No. That doesn't work. There is no way to aggregate the variances from the separate estimates.