How to set complex condition in EViews?

For questions regarding programming in the EViews programming language.

Moderators: EViews Gareth, EViews Jason, EViews Moderator, EViews Matt

banhbengconuong
Posts: 15
Joined: Mon Apr 25, 2011 8:31 pm

How to set complex condition in EViews?

Postby banhbengconuong » Sat May 10, 2014 4:28 am

Dear Eviews experts,

I would like to make a complex condition for the lag of model. Suppose based on SIC criteria, number of lag is "a"
Below is my set of conditions:
if a <3 is true then a=3, else a = a
if a>6 is true then a=6, else a=a
At this moment I am stuck with setting the two conditions by writing 2 separate conditions because a is always either 3 or 6.
Please help me to fix it. Thank you very much!!!!

EViews Glenn
EViews Developer
Posts: 2672
Joined: Wed Oct 15, 2008 9:17 am

Re: How to set complex condition in EViews?

Postby EViews Glenn » Sat May 10, 2014 7:50 am

Code: Select all

a = min(max(a, 3), 6)

banhbengconuong
Posts: 15
Joined: Mon Apr 25, 2011 8:31 pm

Re: How to set complex condition in EViews?

Postby banhbengconuong » Sun May 11, 2014 2:15 am

EViews Glenn wrote:

Code: Select all

a = min(max(a, 3), 6)


I am sorry that when I write:
scalar a=min(max(1, 3), 6)
EViews says "Syntax error". Could you pls check that?
Many thanks

EViews Glenn
EViews Developer
Posts: 2672
Joined: Wed Oct 15, 2008 9:17 am

Re: How to set complex condition in EViews?

Postby EViews Glenn » Mon May 12, 2014 7:18 am

Sorry, use @min and @max.

banhbengconuong
Posts: 15
Joined: Mon Apr 25, 2011 8:31 pm

Re: How to set complex condition in EViews?

Postby banhbengconuong » Mon May 12, 2014 8:24 am

EViews Glenn wrote:Sorry, use @min and @max.


Sorry again, EViews said "too many arguments" even if I choose only scalar a=@min(3,6) for instance.

startz
Non-normality and collinearity are NOT problems!
Posts: 3775
Joined: Wed Sep 17, 2008 2:25 pm

Re: How to set complex condition in EViews?

Postby startz » Mon May 12, 2014 8:38 am

Try

Code: Select all

a = (a<3)*3 +(a>=3)*a
a = (a>6)*6 + (a<=6)*a

EViews Glenn
EViews Developer
Posts: 2672
Joined: Wed Oct 15, 2008 9:17 am

Re: How to set complex condition in EViews?

Postby EViews Glenn » Mon May 12, 2014 12:11 pm

Sorry, I'm thinking in different programming language syntax. To do Startz's excellent suggestion in one line

Code: Select all

a = (a<3)*3 + (a>6)*6 + (a>=3 and a<=6)*a


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 20 guests