## Threshold AR Models

For technical questions regarding estimation of single equations, systems, VARs, Factor analysis and State Space Models in EViews. General econometric questions and advice should go in the Econometric Discussions forum.

Moderators: EViews Gareth, EViews Moderator

donihue
Posts: 137
Joined: Wed Oct 07, 2009 8:51 am

### Threshold AR Models

Hello,

Threshold AR (TAR) models such as STAR, LSTAR, SETAR and so on can be estimated in programmes like RATS, but I have not seen any commands or programmes to do so in EViews.

Does anyone have any experience in estimating Threshold AR (TAR) models in EViews?

Regards
Donihue

Did you use forum search?
Posts: 1518
Joined: Thu Nov 20, 2008 12:04 pm

### Re: Threshold AR Models

You can easily estimate TAR models in EViews via LogL object...

donihue
Posts: 137
Joined: Wed Oct 07, 2009 8:51 am

### Re: Threshold AR Models

I am of course aware that the logl object could be used to set up this type of model. My question was really meant to be more along the lines of "has anyone done it?"

You have already contributed so many useful programmes to this forum, so perhaps you yourself have done so?

Regards
Donihue

Did you use forum search?
Posts: 1518
Joined: Thu Nov 20, 2008 12:04 pm

### Re: Threshold AR Models

Actually, if you do not have a complex model, you can estimate it with NLS instead of LogL object. Suppose that the data generation process is as follows:

Code: Select all

`smpl @first @firstseries y = 1smpl @first+1 @lasty = 2 + 0.85*y(-1) + (3 - 1.5*y(-1))/(1+exp(-15*(y(-1)-6))) + nrndsmpl @all`

Since this model is a simple first order LSTAR model, the estimation can be done via NLS:

Code: Select all

`c(2) = 0.5equation nls.ls y = c(1) + c(2)*y(-1) + (c(3) + c(4)*y(-1))/(1+exp(-c(5)*(y(-1)-c(6))))`

Please note that you may need to assign proper starting values for the coefficents prior to estimation in order to ensure the stability of the model. For instance, setting the autoregressive coefficent value, c(2), to something smaller than 1 could ease the convergence.

You can prefer to use log-likelihood estimation for a more general use. The model above can also be estimated via LogL object:

Code: Select all

`smpl @first @firstseries yf = 1coef(2) alphacoef(2) betacoef(2) thetacoef(1) sigsig(1) = 1alpha(2) = 0.5smpl @all logl lstarlstar.append @logl logllstar.append yf = alpha(1) + alpha(2)*y(-1) + (beta(1) + beta(2)*y(-1))/(1+exp(-theta(1)*(y(-1)-theta(2))))lstar.append res = y - yflstar.append var = sig(1)^2lstar.append z = res/@sqrt(var)lstar.append logl =  log(@dnorm(z)) - log(var)/2smpl @first+1 @lastlstar.ml(showopts, m=1000, c=1e-5)show lstar.outputsmpl @all`

If you encounter any convergence problems, try to assign different starting values to estimated parameters. You should always be careful about the initial conditions when you are dealing with nonlinear models...

donihue
Posts: 137
Joined: Wed Oct 07, 2009 8:51 am

### Re: Threshold AR Models

As always, you are remarkably swift and thoughtful. Many of us with limited programming skills are heavily in your debt, not just for this, but for the many other programmes you have contributed.

Regards
Donihue

student
Posts: 2
Joined: Wed Feb 16, 2011 12:56 pm

### Re: Threshold AR Models

Hello,
Thank you very much for your answer I dound it really useful, although not everything is clear for me, can I use nls to estimate unemployment rate as a dependant and gdp as a independent variable? Also what c(1), c(2) ..., c(6) stands for? I am a new user of eviews and also new to STAR models, so will highly appreciate your help,

Thanks,
Student

Did you use forum search?
Posts: 1518
Joined: Thu Nov 20, 2008 12:04 pm

### Re: Threshold AR Models

STAR models can be applied to many cases as long as the underlying relationship is assumed/verified to be nonlinear. You can find detailed explanation on STAR models in many econometrics textbooks.
c(.)'s are coefficients to be estimated. After the estimation EViews stores their values into a coefficent vector called c, which you can see in the workfile. For a good introduction to EViews, you can start from here: http://www.eviews.com/illustrated/illustrated.html and continue with the user's manual.

student
Posts: 2
Joined: Wed Feb 16, 2011 12:56 pm

### Re: Threshold AR Models

Thank you once again for your help.

Could you please tell me how to expand above logl model to two variable case?
I have tried
two include it in a following way:
lstar.append yf = alpha(1) + alpha(2)*y(-1) + (beta(1) +
beta(2)*y(-1))/(1+exp(-theta(1)*(x(-1)-theta(2))))

but it does not work as it states there is a missing value in
smpl @first+1 @last
lstar.ml(showopts, m=1000, c=1e-5)
show lstar.output

Once again will highly appreciate your help,

Many thanks,
Student

anais
Posts: 2
Joined: Mon Jul 16, 2012 6:18 am

### Re: Threshold AR Models

Hello,

I would like to estimate a SETAR model, but I don't know how to estimate it with Eviews.

Can someone help me to find some procedure for this type of model?

Thanks,

nzarra
Posts: 3
Joined: Mon Aug 06, 2012 5:43 am

### Re: Threshold AR Models

im doing my dissertation on PPP and urgently need the codes to run three-regim TAR(1) model. btw i got three variables.
does anyone know the commands?

icprag
Posts: 6
Joined: Wed Jul 25, 2012 9:06 am

### Re: Threshold AR Models

[quote="trubador"]Actually, if you do not have a complex model, you can estimate it with NLS instead of LogL object. Suppose that the data generation process is as follows:

Code: Select all

`smpl @first @firstseries y = 1smpl @first+1 @lasty = 2 + 0.85*y(-1) + (3 - 1.5*y(-1))/(1+exp(-15*(y(-1)-6))) + nrndsmpl @all`

Since this model is a simple first order LSTAR model, the estimation can be done via NLS:

Code: Select all

`c(2) = 0.5equation nls.ls y = c(1) + c(2)*y(-1) + (c(3) + c(4)*y(-1))/(1+exp(-c(5)*(y(-1)-c(6))))`

Please note that you may need to assign proper starting values for the coefficents prior to estimation in order to ensure the stability of the model. For instance, setting the autoregressive coefficent value, c(2), to something smaller than 1 could ease the convergence.

You can prefer to use log-likelihood estimation for a more general use. The model above can also be estimated via LogL object:
[code]smpl @first @first
series yf = 1

Hi! please allow me a naive question. Although i've understood how logL works, i cannot figure out what "series y=1" stands for

Did you use forum search?
Posts: 1518
Joined: Thu Nov 20, 2008 12:04 pm

### Re: Threshold AR Models

It is necessary for initialization, which you would experience a "missing value (NA)" problem otherwise. Note that the equation includes the first lag of dependent variable and the estimation period starts from the second observation...

icprag
Posts: 6
Joined: Wed Jul 25, 2012 9:06 am

### Re: Threshold AR Models

thank you for your directe response. It is clear now.

Please let me one more question. I wrote down this in the Logl object and when i try to estimate it, it responds as "Syntax error in smpl @first @first"

smpl @first @first
series fedratef=1

coef(4) alpha
coef(4) beta
coef(2) theta
coef(1) sig

sig(1) = 1
alpha(4) = 0.5
beta(4)=0.5
theta(2)=3

smpl @all
logl lstar
lstar.append @logl logl
lstar.append fedratef = alpha(1) + alpha(2)*coreinfl(12) + alpha(3)*outputgap(3)+ alpha(4)*fedrate(-1) +(beta(1)+beta(2)*coreinfl(12)+beta(3)*outputgap(3)+beta(4)*fedrate(-1))*(1-@exp(-theta(1)*(coreinfl(-1)-theta(2))^2))
lstar.append res = fedrate - fedratef
lstar.append var = sig(1)^2
lstar.append z = res/@sqrt(var)
lstar.append logl = log(@dnorm(z)) - log(var)/2

smpl @first+1 @last
lstar.ml(showopts, m=1000, c=1e-5)
show lstar.output

smpl @all

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 12573
Joined: Tue Sep 16, 2008 5:38 pm

### Re: Threshold AR Models

You need to put all that in a program.

irfan alam
Posts: 3
Joined: Sat Oct 21, 2017 3:01 am

### Re: Threshold AR Models

I need your guidance regarding Threshold autoregressive model in eview.
My course of research is dependent variable "Real effective exchange rate"and follow a list of independent variables such as "Debt to Gdp, Nfa etc. and my data consist of 8 countries during the period of 2001 to 2016. I want to know that who can i estimate TAR model in eviews.