How to skip a regression when it has an error

For questions regarding programming in the EViews programming language.

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

nesheus
Posts: 34
Joined: Tue Oct 26, 2010 11:55 am

How to skip a regression when it has an error

Postby nesheus » Wed Dec 01, 2010 12:58 pm

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13585
Joined: Tue Sep 16, 2008 5:38 pm

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

Postby EViews Gareth » Wed Dec 01, 2010 1:03 pm

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

nesheus
Posts: 34
Joined: Tue Oct 26, 2010 11:55 am

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

Postby nesheus » Wed Dec 01, 2010 1:08 pm

thanks. Are you sure the spelling is correct because I get this error when I used it
@lasterrnum is an illegal or reserved name

nesheus
Posts: 34
Joined: Tue Oct 26, 2010 11:55 am

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

Postby nesheus » Wed Dec 01, 2010 1:12 pm

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

nesheus
Posts: 34
Joined: Tue Oct 26, 2010 11:55 am

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

Postby nesheus » Wed Dec 01, 2010 1:14 pm

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.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13585
Joined: Tue Sep 16, 2008 5:38 pm

How to skip a regression when it has an error

Postby EViews Gareth » Wed Dec 01, 2010 1:47 pm

Which version of EViews?

nesheus
Posts: 34
Joined: Tue Oct 26, 2010 11:55 am

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

Postby nesheus » Wed Dec 01, 2010 1:51 pm

Eviews 6

nesheus
Posts: 34
Joined: Tue Oct 26, 2010 11:55 am

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

Postby nesheus » Wed Dec 01, 2010 1:54 pm

Could you respond to my question on what to check without interrupting the program and skip this regression?
Thanks

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13585
Joined: Tue Sep 16, 2008 5:38 pm

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

Postby EViews Gareth » Wed Dec 01, 2010 2:09 pm

EViews 6 doesn't have @lasterrnum.


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

nesheus
Posts: 34
Joined: Tue Oct 26, 2010 11:55 am

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

Postby nesheus » Wed Dec 01, 2010 2:17 pm

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

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13585
Joined: Tue Sep 16, 2008 5:38 pm

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

Postby EViews Gareth » Wed Dec 01, 2010 2:20 pm

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.

nesheus
Posts: 34
Joined: Tue Oct 26, 2010 11:55 am

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

Postby nesheus » Wed Dec 01, 2010 2:22 pm

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.
Last edited by nesheus on Wed Dec 01, 2010 3:45 pm, edited 1 time in total.

EViews Gareth
Fe ddaethom, fe welon, fe amcangyfrifon
Posts: 13585
Joined: Tue Sep 16, 2008 5:38 pm

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

Postby EViews Gareth » Wed Dec 01, 2010 2:29 pm

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.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests