SETAR Model: multi-step-ahead rolling forecasts

Discussion of models with structural breaks or endogenous switching.

SETAR Model: multi-step-ahead rolling forecasts

Unread postby ac_1 » Sat Feb 06, 2021 6:35 am

Hi Tom,

Can a SETAR model be applied to a non-stationary series or is the only requirement to check for non-linearity? I can generate one-step ahead rolling forecasts using threshtest.src to estimate the break and to generate forecasts within a DO loop.

Code: Select all
set onestep = setar(t)
group lsetarmodel setar
forecast(model=lsetarmodel,results=fcasts) * 1 ibegin+1+j

How do I generate multi-step-ahead rolling forecasts saving only the last forecast step as in FORECAST instruction SKIPSAVE? https://estima.com/ratshelp/index.html? ... ction.html

many thanks,
Amarjit
ac_1
 
Posts: 296
Joined: Thu Apr 15, 2010 6:30 am
Location: London, UK

Re: SETAR Model: multi-step-ahead rolling forecasts

Unread postby TomDoan » Sat Feb 06, 2021 11:54 am

There is no closed-form formula for out-of-sample forecasting in a threshold model.
TomDoan
 
Posts: 7388
Joined: Wed Nov 01, 2006 5:36 pm

Re: SETAR Model: multi-step-ahead rolling forecasts

Unread postby ac_1 » Sat Feb 06, 2021 1:39 pm

TomDoan wrote:There is no closed-form formula for out-of-sample forecasting in a threshold model.

Not even for one-step ahead? I have read on the Web, static or one-step ahead forecasting is straightforward and uses the estimated equations.

If not straightforward, then I guess simulations to generate out-of-sample forecasts? Right? Please can you provide an example to generate one-step ahead and multi-step-ahead rolling forecasts.
ac_1
 
Posts: 296
Joined: Thu Apr 15, 2010 6:30 am
Location: London, UK

Re: SETAR Model: multi-step-ahead rolling forecasts

Unread postby ac_1 » Thu Mar 24, 2022 3:31 am

Hi Tom,

Based on Example 4.1 TAR Model for Unemployment, here's an attempt at recursive STATIC ONE-STEP AHEAD FORECASTS generated from a SETAR model. Please can you have a look - I think it's correct.

Code: Select all
*===============================
*
* RECURSIVE STATIC ONE-STEP AHEAD OOS FORECASTS
*
*
seed 550103
*
clear(length=2010:10) urfore_1
*
do regend = 2010:10-13, 2010:10
*
@threshtest(thresh=dur,d=1,nreps=100) dur * regend
# constant dur{1 to 4}
*
compute break1=%%breakvalue
disp break1
*
* Estimate the two branches and define equations
*
linreg(smpl=dur{1}<=break1,frml=branch1) dur * regend
# constant dur{1 to 4}
compute rss1=%rss,ndf1=%ndf
linreg(smpl=dur{1}>break1,frml=branch2) dur * regend
# constant dur{1 to 4}
compute rss2=%rss,ndf2=%ndf
compute seesq=(rss1+rss2)/(ndf1+ndf2)
*
*
* Define the forecasting model
*
frml(variance=seesq) tarfrml dur = $
      %if(dur{1}<=break1,branch1,branch2)
frml(identity) urid unrate = unrate{1}+dur
group tarmodel tarfrml urid
*
*
* Compute average across simulations
*
compute fstart=regend,fend=regend
set urfore_1 regend regend = 0.0
compute ndraws=5000
do draw=1,ndraws
   simulate(model=tarmodel,from=regend,to=regend,results=sims_1,noprint)
   set urfore_1 regend regend = urfore_1+sims_1(2)
end do draw
set urfore_1 regend regend = urfore_1/ndraws
*
*
end do regend
*
graph(footer="RECURSIVE STATIC ONE-STEP AHEAD OOS FORECASTS") 2
# unrate regend-13 regend
# urfore_1
*
prin fstart-13 regend unrate urfore_1

How do I calculate forecast SE's for Prediction intervals?


I also want to compute nth-step-ahead forecasts, DYNAMIC MULTISTEP AHEAD OOS FORECASTS and save only the nth forecast step from each recursive multistep ahead simulation...

many thanks,
Amarjit
ac_1
 
Posts: 296
Joined: Thu Apr 15, 2010 6:30 am
Location: London, UK

Re: SETAR Model: multi-step-ahead rolling forecasts

Unread postby ac_1 » Mon Mar 28, 2022 1:25 am

I've managed to generate STATIC ONE-STEP AHEAD OOS FORECASTS, adjusting via regend+1 in SIMULATE; and have generated DYNAMIC MULTISTEP AHEAD OOS FORECASTS saving only the nth forecast step.

The question is how to simulate the forecast SE's, which are method specific e.g. SETAR-AR(p), for prediction intervals?
ac_1
 
Posts: 296
Joined: Thu Apr 15, 2010 6:30 am
Location: London, UK

Re: SETAR Model: multi-step-ahead rolling forecasts

Unread postby TomDoan » Tue Mar 29, 2022 8:04 pm

ac_1 wrote:I've managed to generate STATIC ONE-STEP AHEAD OOS FORECASTS, adjusting via regend+1 in SIMULATE; and have generated DYNAMIC MULTISTEP AHEAD OOS FORECASTS saving only the nth forecast step.

The question is how to simulate the forecast SE's, which are method specific e.g. SETAR-AR(p), for prediction intervals?


Theoretically, what you are doing is generating a sample of size N from the population of values for the process conditional on the last observed value. The "forecast" is the mean of that population. The standard error of forecast is the standard error of that distribution.
TomDoan
 
Posts: 7388
Joined: Wed Nov 01, 2006 5:36 pm

Re: SETAR Model: multi-step-ahead rolling forecasts

Unread postby ac_1 » Wed Mar 30, 2022 9:19 am

TomDoan wrote:Theoretically, what you are doing is generating a sample of size N from the population of values for the process conditional on the last observed value. The "forecast" is the mean of that population. The standard error of forecast is the standard error of that distribution.

Thanks.

Here's an attempt. Correct?
Code: Select all
compute ndraws=5000
do draw=1,ndraws
   simulate(model=tarmodel,from=regend+1,to=regend+1,results=sims_1,noprint)
   set urfore_1 regend+1 regend+1 = urfore_1+sims_1(2)
   set urfore_1_M regend+1 regend+1 = urfore_1/draw
   set urfore_1_VAR regend+1 regend+1 = urfore_1_VAR + ((sims_1(2)-urfore_1_M)^2)/draw
   set urfore_1_SE regend+1 regend+1 = sqrt(urfore_1_VAR)
end do draw
ac_1
 
Posts: 296
Joined: Thu Apr 15, 2010 6:30 am
Location: London, UK

Re: SETAR Model: multi-step-ahead rolling forecasts

Unread postby TomDoan » Wed Mar 30, 2022 9:32 am

No. The averages are done outside the loop. Inside, you accumulate the sums and sums of squares (since you don't know the mean, you just do raw sums of squares), then convert to mean and variance/standard error outside the loop.
TomDoan
 
Posts: 7388
Joined: Wed Nov 01, 2006 5:36 pm

Re: SETAR Model: multi-step-ahead rolling forecasts

Unread postby ac_1 » Wed Mar 30, 2022 10:38 am

TomDoan wrote:No. The averages are done outside the loop. Inside, you accumulate the sums and sums of squares (since you don't know the mean, you just to raw sums of squares), then convert to mean and variance/standard error outside the loop.

A better attempt :) . Correct?
Code: Select all
compute ndraws=5000
do draw=1,ndraws
   simulate(model=tarmodel,from=regend+1,to=regend+1,results=sims_1,noprint)
   set urfore_1 regend+1 regend+1 = urfore_1+sims_1(2)
   set urfore_1_SS regend+1 regend+1 = urfore_1_SS+(sims_1(2))^2
end do draw
set urfore_1_M regend+1 regend+1 = urfore_1/ndraws
set urfore_1_MSS regend+1 regend+1 = urfore_1_SS/ndraws
set urfore_1_SE regend+1 regend+1 = sqrt(urfore_1_MSS-(urfore_1_M)^2)
ac_1
 
Posts: 296
Joined: Thu Apr 15, 2010 6:30 am
Location: London, UK

Re: SETAR Model: multi-step-ahead rolling forecasts

Unread postby TomDoan » Wed Mar 30, 2022 4:17 pm

That looks correct. You might need to experiment with the number of draws to see how many it takes to get the standard errors to stabilize. 5000 may be (probably is) enough for the mean itself, but might not be for the standard errors.
TomDoan
 
Posts: 7388
Joined: Wed Nov 01, 2006 5:36 pm

Re: SETAR Model: multi-step-ahead rolling forecasts

Unread postby ac_1 » Sun Apr 03, 2022 3:47 am

Generating the following with SIMULATE:

1. DYNAMIC h-MULTISTEP AHEAD OOS FORECASTS
2. STATIC ONE-STEP AHEAD OOS FORECASTS
3. DYNAMIC h-MULTISTEP AHEAD OOS FORECASTS saving only the (e.g) 4th forecast step

With the same seed, repeated, before each of the above 1-3, I should get identical MC forecasts comparing:

(a) DYNAMIC h-MULTISTEP AHEAD OOS FORECASTS vs. STATIC ONE-STEP AHEAD OOS FORECASTS; for the 1st forecast
(b) DYNAMIC h-MULTISTEP AHEAD OOS FORECASTS vs. DYNAMIC h-MULTISTEP AHEAD OOS FORECASTS saving only the 4th forecast step; for the (first) 4th forecast

as I do for LINEAR forecasts, but I do not. Why would that be?
ac_1
 
Posts: 296
Joined: Thu Apr 15, 2010 6:30 am
Location: London, UK

Re: SETAR Model: multi-step-ahead rolling forecasts

Unread postby TomDoan » Tue Apr 05, 2022 2:45 pm

Calculations with random numbers are only guaranteed to give identical results with a set SEED if the instructions executed are identical---it's basically for reproducing an entire program. It's possible for two different instructions to give at least some results which are the same, but that's just blind luck---it depends upon the internal order of the random draws. For instance, if you do

SEED 534323
compute a1=%ranmat(10,1),a2=%ranmat(10,1)
SEED 534323
compute b=%ranmat(20,1)

the first 10 elements of B will match A1, but the second 10 won't match A2 because firing up the second %RANMAT to get A2 changes the random number generation.


Last bumped by TomDoan on Tue Apr 05, 2022 2:45 pm.
TomDoan
 
Posts: 7388
Joined: Wed Nov 01, 2006 5:36 pm


Return to Structural Breaks and Switching Models

Who is online

Users browsing this forum: No registered users and 2 guests

cron