Code Distinguishing IVs from Endogenous Variables

For questions regarding programming in the EViews programming language.

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

diggetybo
Posts: 152
Joined: Mon Jun 23, 2014 12:04 am

Code Distinguishing IVs from Endogenous Variables

Postby diggetybo » Fri Oct 23, 2015 10:25 am

Hello again,

The capture log and user guide have both been invaluable in my study on two stage LS. I'm hitting a roadblock, when I try to retrieve the p value from the chi sq distribution. The following chi sq syntax I found on pg 161 of eviews 8 object reference, but perhaps a different syntax is needed here? That's question #1.

Have a look at my simple program (almost complete):

Code: Select all

equation 2SLS_eq.tsls y1 c y2 x1 x2 @ x1 x2 iv1 iv2 series error_hat = resid equation overspec_eq.ls error_hat c x1 x2 iv1 iv2 scalar chi_val = overspec_eq.@regobs*overspec_eq.@r2 scalar chi_pval = chi_val.@chisqprob(1)
For clarity, it's a chisq(1) distribution because the instruments outside the equation total two (iv1, iv2), and the endogenous variables total 1 (y2), i.e 2-1=1.

Question #2: In the program above, I put a 1 after @chisqprob(1), assuming that's what goes inside the parentheses -- the order, but I got an error, so I'm probably wrong. Nevertheless, once that's straightened out, I would like to improve the code in this procedure for the general case. Instead of a 1 or whatever goes there, I wanted to use code to reference the count of instruments outside the equation minus the endogenous variables. This way, whether I have 2, 3, or 4 IV's or 3-4 or endogenous variables or whatever combination of the two may be, my program will be robust in computing the correct chisq pval.

Thanks for reading

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

Re: Code Distinguishing IVs from Endogenous Variables

Postby EViews Gareth » Fri Oct 23, 2015 10:28 am


diggetybo
Posts: 152
Joined: Mon Jun 23, 2014 12:04 am

Re: Code Distinguishing IVs from Endogenous Variables

Postby diggetybo » Mon Oct 26, 2015 4:53 am

Thanks again Gareth for the relevant link to distribution commands. For the last line of my code I use

Code: Select all

scalar chi_pval = @dchisq(chisq_val,1)
So to fully address Question #2 above, does eviews have a certain syntax to discern between the instruments and the endogenous variables in an existing equation? If not is there any other way to circumvent this problem?

This way instead of using "1" for the degrees of freedom in my code, I can compute the degrees of freedom by subtracting the instruments from the endogenous variables and use my code for various degrees of freedom 2SLS and not have to micro manage my lines of code each time I use it for different regressions.

--EDIT--
Question #1 may warrant a further look, as when I ran the code for a case with two over identifying restrictions where n=428 and r2=.0026:

Code: Select all

scalar chisq_pval = @dchisq(1.11,2)
I got an answer of .286. Which is twice the value of the book's correct answer of .574. Is there something wrong with my syntax?

diggetybo
Posts: 152
Joined: Mon Jun 23, 2014 12:04 am

Re: Code Distinguishing IVs from Endogenous Variables

Postby diggetybo » Fri Oct 30, 2015 8:03 am

I'm still trying to circumvent this little problem, the thing I tried that works somewhat lately, is setting up local variable groups for IV's and endogenous variables as configurable, so each equation can be distinct in that respect.

However the issue remains for more complicated 2TLS even this way is time consuming. Is there anything built-in or any means to discern IV's from other variables in eviews programming? For instance to calculate the degrees of freedom for a simple over identification test, I'd need to know the number of IV's and the number of endogenous variables, so for code I'd need something like eq.@instrumentcount or eq.@endogvariablecount, know what I mean? If I'm not clear, please let me know.


Return to “Programming”

Who is online

Users browsing this forum: No registered users and 1 guest