Page 1 of 1

How to skip a regression when it has an error

Posted: Wed Dec 01, 2010 12:58 pm
by nesheus
Please see a segment of my program. In the regression equation, it cannot produce coefficients because it has a singular matrix. So tstat(1) gives "division by zero" error and stops the program.
I do this for many equations in a very long program. I need to detect this error and skip to calculate the t-statistics and continue to the other part of program but I cannot do it.
Is there any way of catching that regression didn't produce any estimation and skip it? I hope my explanation is clear. Thanks for your help.

equation eqalum1_12c.ls d(lalum) c ar(1) ma(1) ma(2) dum2 dum3 dum4 dum08Q4

if (@isna(eqalum1_12c.@tstat(1))=0) then
scalar p1_12c = @tdist(eqalum1_12c.@tstat(1), @regobs - eqalum1_12c.@ncoefs)
endif

Re: How to skip a regression when it has an error

Posted: Wed Dec 01, 2010 1:03 pm
by EViews Gareth
You can use the @lasterrnum command to catch whether the previous line of a program caused an error or not. Thus something like:

Code: Select all

equation eqalum1_12c.ls d(lalum) c ar(1) ma(1) ma(2) dum2 dum3 dum4 dum08Q4 if @lasterrnum=0 then 'no error caused stuff else 'error caused stuff endif

Re: How to skip a regression when it has an error

Posted: Wed Dec 01, 2010 1:08 pm
by nesheus
thanks. Are you sure the spelling is correct because I get this error when I used it
@lasterrnum is an illegal or reserved name

Re: How to skip a regression when it has an error

Posted: Wed Dec 01, 2010 1:12 pm
by nesheus
Actually, I should also point out that the regression line doesn't create any error. Only when i try to use the tstatistics I get an error (division by zero).

Re: How to skip a regression when it has an error

Posted: Wed Dec 01, 2010 1:14 pm
by nesheus
Also, I cannot find this function, @lasterrnum? Where do you go or how do you search? I don't think Eviews help is easy to find anything by simply typing.

How to skip a regression when it has an error

Posted: Wed Dec 01, 2010 1:47 pm
by EViews Gareth
Which version of EViews?

Re: How to skip a regression when it has an error

Posted: Wed Dec 01, 2010 1:51 pm
by nesheus
Eviews 6

Re: How to skip a regression when it has an error

Posted: Wed Dec 01, 2010 1:54 pm
by nesheus
Could you respond to my question on what to check without interrupting the program and skip this regression?
Thanks

Re: How to skip a regression when it has an error

Posted: Wed Dec 01, 2010 2:09 pm
by EViews Gareth
EViews 6 doesn't have @lasterrnum.


You can use @errorcount to check how many errors have occurred.

Re: How to skip a regression when it has an error

Posted: Wed Dec 01, 2010 2:17 pm
by nesheus
The regression does not have errors. Simply it doesn't converge. So when I try to calculate the t-statistics I get an error. Could you read my earlier messages. I should find a way of detecting that this regression did not do any estimation. I tried @coeff etc but could find a way. when i try t-statistics I get an error of division by zero.
Here is my regression result

WARNING: Singular covariance - coefficients are not unique
MA Backcast: OFF (Roots of MA process too large)

Variable Coefficient Std. Error t-Statistic Prob.

C 0.027287 NA NA NA
DUM2 -0.008653 NA NA NA
DUM3 -0.032919 NA NA NA
DUM4 0.013356 NA NA NA
DUM08Q4 -0.480224 NA NA NA
AR(1) -0.808295 NA NA NA
MA(1) 1.438928 NA NA NA
MA(2) 0.030255 NA NA NA

Re: How to skip a regression when it has an error

Posted: Wed Dec 01, 2010 2:20 pm
by EViews Gareth
I read your message. Seems to me that you can just calculate the t-statistic and check whether that calculation caused an error or not.

Of course if you really want to test whether the t-statistic (standard error) is equal to an NA or not, you could just do that.

Re: How to skip a regression when it has an error

Posted: Wed Dec 01, 2010 2:22 pm
by nesheus
That is what I am doing here in the if statement

if (@isna(eqalum1_12c.@tstat(1))=0) then


but I get an error message of division by zero and the program stops.

Re: How to skip a regression when it has an error

Posted: Wed Dec 01, 2010 2:29 pm
by EViews Gareth
Without running your code it is really hard to know what you're doing wrong.

I've spent an hour giving you three different solutions to your potential problem.