A TAR model with three regimes

Discussion of models with structural breaks or endogenous switching.
Brc
Posts: 18
Joined: Thu Jun 20, 2024 5:16 pm

A TAR model with three regimes

Unread post by Brc »

Dear Tom,

So far, I'm estimating a TAR model with two regimes. However, I could not find any RATs codes for a TAR model with three regimes. Can you please help me to find RATs codes for TAR model with 3 regimes or please help me to transform TAR model with 2 regimes to with 3 regimes?


I transform the model with 2 regimes to 3 regimes by myself as follows. However, I do not know whether this is correct or not.

Code: Select all

**** Estimate TAR model with 3 regimes*********
COMPUTE LOW = 2003:2 + FIX(.15*%NOBS)
COMPUTE MEDIUM = 2017:1
COMPUTE HIGH = 2025:2 - FIX(.15*%NOBS)
COMPUTE RSSTEST = 1000000.0
SET RSS = 0.
SET THRESHTEST = Z
ORDER THRESHTEST
COMPUTE THRESH1 = THRESHTEST(LOW)
COMPUTE THRESH2 = THRESHTEST(MEDIUM)
DO I = LOW, HIGH
   SET G = %IF(Z{2}<THRESHTEST(I),0,1)
   SET M = %IF(Z{4}<THRESHTEST(I),0,1)
   SET R = 1 - G - M
**
**
   SET GZ1 = G*Z{1}
   SET GZ2 = G*Z{2}
   SET GZ3 = G*Z{3}
   SET GZ4 = G*Z{4}
   SET GZ5 = G*Z{5}
   SET GZ6 = G*Z{6}
   SET GZ7 = G*Z{7}
   SET GZ8 = G*Z{8}
   SET GZ9 = G*Z{9}
**
   SET MZ1 = M*Z{1}
   SET MZ2 =  M*Z{2}
   SET MZ3 = M*Z{3}
   SET MZ4 = M*Z{4}
   SET MZ5 = M*Z{5}
   SET MZ6 = M*Z{6}
   SET MZ7 = M*Z{7}
   SET MZ8 = M*Z{8}
   SET MZ9 = M*Z{9}

**
  ***********************
   SET RZ1 = R*Z{1}
   SET RZ2 = R*Z{2}
   SET RZ3 = R*Z{3}
   SET RZ4 = R*Z{4}
   SET RZ5 = R*Z{5}
   SET RZ6 = R*Z{6}
   SET RZ7 = R*Z{7}
   SET RZ8 = R*Z{8}
   SET RZ9 = R*Z{9}
**
**************
   LINREG(NOPRINT) Z
   # G GZ1 GZ2 GZ3 GZ4 GZ5 GZ6 GZ7 GZ8 GZ9 M MZ1 MZ2 MZ3 MZ4 MZ5 MZ6 MZ7 MZ8 MZ9 $
 R RZ1 RZ2 RZ3 RZ4 RZ5 RZ6 RZ7 RZ8 RZ9
 **
   COM RSS(I) = %RSS
   IF %RSS < RSSTEST {
   	COMPUTE RSSTEST = %RSS
   	COMPUTE THRESH = THRESHTEST(i)
   }
ENDO DO I
DIS 'ATTRACTOR'
DIS 'THRESHOLD1 = ' THRESH1
DIS 'THRESHOLD2 = ' THRESH2
   ***
 SET G = %IF(Z{2}<THRESHTEST(I),0,1)
   SET M = %IF(Z{4}<THRESHTEST(I),0,1)
   SET R = 1 - G - M
**
**
   SET GZ1 = G*Z{1}
   SET GZ2 = G*Z{2}
   SET GZ3 = G*Z{3}
   SET GZ4 = G*Z{4}
   SET GZ5 = G*Z{5}
   SET GZ6 = G*Z{6}
   SET GZ7 = G*Z{7}
   SET GZ8 = G*Z{8}
   SET GZ9 = G*Z{9}
**
   SET MZ1 = M*Z{1}
   SET MZ2 = M*Z{2}
   SET MZ3 = M*Z{3}
   SET MZ4 = M*Z{4}
   SET MZ5 = M*Z{5}
   SET MZ6 = M*Z{6}
   SET MZ7 = M*Z{7}
   SET MZ8 = M*Z{8}
   SET MZ9 = M*Z{9}

**
  ***********************
   SET RZ1 = R*Z{1}
   SET RZ2 = R*Z{2}
   SET RZ3 = R*Z{3}
   SET RZ4 = R*Z{4}
   SET RZ5 = R*Z{5}
   SET RZ6 = R*Z{6}
   SET RZ7 = R*Z{7}
   SET RZ8 = R*Z{8}
   SET RZ9 = R*Z{9}
**
**************
   LINREG(PRINT) Z
   # G GZ1 GZ2 GZ3 GZ4 GZ5 GZ6 GZ7 GZ8 GZ9 M MZ1 MZ2 MZ3 MZ4 MZ5 MZ6 MZ7 MZ8 MZ9 $
 R RZ1 RZ2 RZ3 RZ4 RZ5 RZ6 RZ7 RZ8 RZ9
 **
***********
sca(Header='Residual Sums of Squares',style=lines,hlabel='Threshold') 1 ;
#  threshtest rss low medium high
GRAPH 1
# Z
Thank you so much.

Best Regards.
TomDoan
Posts: 7774
Joined: Wed Nov 01, 2006 4:36 pm

Re: A TAR model with three regimes

Unread post by TomDoan »

That's a really crude way to handle that. Use the @MULTIPLEBREAKS procedure instead. Note, however, that if you don't really find even one break, you are very unlikely to find two.
Post Reply