We are running a model where the model stops running spitting a error message saying that " log of non-positive number". After tracing the variables, we found that one of the variables becoming negative for which the log can not be created. As a result, the model stopped running at this point. I was wondering is there any way to incorporate in the model an if else statement so that whenever any variable encounters a negative number it is forced to a positive no. Like the following statement:
if x<0 then
x=.005
else
x=x
endif
I tried to put this in the model text but it generated error.
Any help on this would be highly appreciated.
Log of non-positive number
Moderators: EViews Gareth, EViews Moderator, EViews Jason, EViews Matt
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13585
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Log of non-positive number
Use the @recode function
Re: Log of non-positive number
Thanks a lot for your response. I am still finding it difficult to implement the code.
Let me elaborate a bit. One of the variables, say, ygdp has become negative. So, I would put the code in the model text
@recode((ygdp<0),(ygdp=.005),(ygdp=ygdp))
Basically, I am trying to tell the model that if ygdp<0, then put ygdp=.005 else ygdp stays as ygdp.
But it is generating syntax error. Any idea, what went wrong?
Let me elaborate a bit. One of the variables, say, ygdp has become negative. So, I would put the code in the model text
@recode((ygdp<0),(ygdp=.005),(ygdp=ygdp))
Basically, I am trying to tell the model that if ygdp<0, then put ygdp=.005 else ygdp stays as ygdp.
But it is generating syntax error. Any idea, what went wrong?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13585
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Log of non-positive number
Code: Select all
ygdp = @recode(ygdp<0, ygdp, 0.005)
Re: Log of non-positive number
Let expand on my problem a bit more.
What you see above is the text view from a model object. I can not write ygdp=@recode(ygdp<0 , .005 , ygdp) because we can not have the same
endogenous variable defined twice in the same model. But the above formulation is generating syntax error. Actually this is one I first tried and then resort to the second one which I mentioned in my earlier post. Any ideas?
Code: Select all
YGDP = CP + IP + G + YEXP - YIMP
@recode(ygdp<0 , .005 , ygdp)
YD = YGDP - IT + TR + SUB
NYD = YD + REMD * exr
endogenous variable defined twice in the same model. But the above formulation is generating syntax error. Actually this is one I first tried and then resort to the second one which I mentioned in my earlier post. Any ideas?
-
EViews Gareth
- Fe ddaethom, fe welon, fe amcangyfrifon
- Posts: 13585
- Joined: Tue Sep 16, 2008 5:38 pm
Re: Log of non-positive number
Code: Select all
temp = CP + IP + G + YEXP - YIMP
@identity ygdp = @recode(temp<0 , .005 , temp)
YD = YGDP - IT + TR + SUB
NYD = YD + REMD * exr
Who is online
Users browsing this forum: No registered users and 2 guests
