Page 1 of 1

How to set complex condition in EViews?

Posted: Sat May 10, 2014 4:28 am
by banhbengconuong
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!!!!

Re: How to set complex condition in EViews?

Posted: Sat May 10, 2014 7:50 am
by EViews Glenn

Code: Select all

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

Re: How to set complex condition in EViews?

Posted: Sun May 11, 2014 2:15 am
by banhbengconuong

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

Re: How to set complex condition in EViews?

Posted: Mon May 12, 2014 7:18 am
by EViews Glenn
Sorry, use @min and @max.

Re: How to set complex condition in EViews?

Posted: Mon May 12, 2014 8:24 am
by banhbengconuong
Sorry, use @min and @max.
Sorry again, EViews said "too many arguments" even if I choose only scalar a=@min(3,6) for instance.

Re: How to set complex condition in EViews?

Posted: Mon May 12, 2014 8:38 am
by startz
Try

Code: Select all

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

Re: How to set complex condition in EViews?

Posted: Mon May 12, 2014 12:11 pm
by EViews Glenn
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