Page **1** of **2**

### Threshold AR Models

Posted: **Sat Feb 12, 2011 2:33 am**

by **donihue**

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

### Re: Threshold AR Models

Posted: **Mon Feb 14, 2011 12:38 am**

by **trubador**

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

### Re: Threshold AR Models

Posted: **Tue Feb 15, 2011 10:27 am**

by **donihue**

Thank you for your response, Trubador.

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

### Re: Threshold AR Models

Posted: **Wed Feb 16, 2011 1:20 am**

by **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 @first`

series y = 1

smpl @first+1 @last

y = 2 + 0.85*y(-1) + (3 - 1.5*y(-1))/(1+exp(-15*(y(-1)-6))) + nrnd

smpl @all

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

Code: Select all

`c(2) = 0.5`

equation 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 @first`

series yf = 1

coef(2) alpha

coef(2) beta

coef(2) theta

coef(1) sig

sig(1) = 1

alpha(2) = 0.5

smpl @all

logl lstar

lstar.append @logl logl

lstar.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 - yf

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

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...

### Re: Threshold AR Models

Posted: **Wed Feb 16, 2011 10:34 am**

by **donihue**

Thank you very much, Trubador!

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

### Re: Threshold AR Models

Posted: **Mon Feb 21, 2011 10:48 am**

by **student**

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

### Re: Threshold AR Models

Posted: **Tue Feb 22, 2011 1:30 am**

by **trubador**

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.

### Re: Threshold AR Models

Posted: **Thu Feb 24, 2011 11:02 am**

by **student**

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

### Re: Threshold AR Models

Posted: **Mon Jul 16, 2012 6:25 am**

by **anais**

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,

### Re: Threshold AR Models

Posted: **Mon Aug 06, 2012 5:53 am**

by **nzarra**

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?

thanks in advance

### Re: Threshold AR Models

Posted: **Tue Feb 12, 2013 12:15 am**

by **icprag**

[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 @first`

series y = 1

smpl @first+1 @last

y = 2 + 0.85*y(-1) + (3 - 1.5*y(-1))/(1+exp(-15*(y(-1)-6))) + nrnd

smpl @all

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

Code: Select all

`c(2) = 0.5`

equation 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

### Re: Threshold AR Models

Posted: **Tue Feb 12, 2013 3:33 am**

by **trubador**

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...

### Re: Threshold AR Models

Posted: **Tue Feb 12, 2013 5:42 am**

by **icprag**

Dear Trubador,

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"

Could you please help me?

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

### Re: Threshold AR Models

Posted: **Tue Feb 12, 2013 7:16 am**

by **EViews Gareth**

You need to put all that in a program.

### Re: Threshold AR Models

Posted: **Mon Nov 20, 2017 12:46 am**

by **irfan alam**

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.