Using for loops with GMM

For questions regarding programming in the EViews programming language.

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

jms
Posts: 2
Joined: Thu Dec 18, 2008 5:23 am

Using for loops with GMM

Postby jms » Thu Dec 18, 2008 5:36 am

I am trying to estimate some equations by GMM recursively and with a rolling window. In particular, I am trying to estimate the following:

for !j = 1 to 131

smpl 1993:1 1993:1+!j+60

equation recursive.gmm(b=v,deriv=aa) I=(1-C(4)-C(5))*(C(1)+C(2)*X+C(3)*Y)+C(4)*I(-1)+C(5)*I(-2) @ X(-1 TO -3) Y(-1 TO -3) C I(-1 TO -2)

next !j

But it tells me I have a near singular matrix. Is there an obvious error in this code? If I am not using the loop I can easily estimate the equation over the shorter sample (i.e. if estimate the equation for the sample when !j = 1) but when I use the loop I get the error message. Can you tell me how I can get round this bug please?

trubador
Did you use forum search?
Posts: 1520
Joined: Thu Nov 20, 2008 12:04 pm

Re: Using for loops with GMM

Postby trubador » Thu Dec 18, 2008 6:33 am

I do not think your problem has anything to do with the code. However, I understand your sample period is January 1993 - December 2008. The code you have written creates an expanding window rather than a rolling one. If you actually wanted to create a rolling window of span 60, then you had to change the beginning of the sample accordingly.

Near singular matrix is generally an issue of estimation process. It means that EViews is not able to take the inverse of a matrix (i.e. its determinant is zero). EViews begins the estimation with using the values stored in "c" coefficient vector in the workfile. And these values equal to zero at the beginning. After each estimation, final results are also stored in that vector and subsequent estimation attempt will take these values as input. It is also important that whether you receive the error message immediately after beginning the estimation or some time later. Since your equation appears to be of nonlinear form, the problem may either be caused by starting values or statistical properties of data itself.

All in all, you should provide more information on your problem or simply share your EViews worfile..

learner
Posts: 13
Joined: Sat Jun 27, 2009 7:09 am

Re: Using for loops with GMM

Postby learner » Mon Jul 02, 2012 4:11 am

Hi
I would like to know how to estimate Rolling Window GMM. (keeping the window size fixed). It would be nice if anyone directs me to the link estimating rolling window GMM on the Eviews forum or write it down.
Thanks a lot.

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

Re: Using for loops with GMM

Postby EViews Gareth » Mon Jul 02, 2012 7:49 am

There are lots of examples of doing rolling regression on the forum (you can do a search). Changing that to perform GMM rather than least squares is trivial.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 2 guests