Coputation of fitted values

For technical questions regarding estimation of single equations, systems, VARs, Factor analysis and State Space Models in EViews. General econometric questions and advice should go in the Econometric Discussions forum.

Moderators: EViews Gareth, EViews Moderator

oksanakim
Posts: 35
Joined: Wed Apr 04, 2012 10:38 am

Coputation of fitted values

Postby oksanakim » Thu Sep 21, 2017 9:40 am

Dear Moderators and Eviews users,

I am trying to estimate a 2SLS in two stages, rather using the Eviews' built in option. In the first stage, I regress my endogenous variable Femaledir on all exogenous variables and the instrument, as suggested. How do I then compute fitted values for Femaledir from the output of this first stage estimation, that I can then use in the second stage to replace femaledir? Thank you very much!!

startz
Non-normality and collinearity are NOT problems!
Posts: 3138
Joined: Wed Sep 17, 2008 2:25 pm

Re: Coputation of fitted values

Postby startz » Thu Sep 21, 2017 9:45 am

Use the fit command.

As you probably know, estimating 2sls manually in two stages does not give the correct standard errors.

oksanakim
Posts: 35
Joined: Wed Apr 04, 2012 10:38 am

Re: Coputation of fitted values

Postby oksanakim » Thu Sep 21, 2017 9:54 am

Thank you Startz! Do you suggest that the second-stage estimation will be incorrect? The reason I fell for the manual estimation is because the Eviews' built in option returns negative R-squared and some menaingless results, compared to standard OLS estimation. This is why I decided to try manual estimation. Is there any way to correct the standard errors? And can you please be more specific as to the sintax for fit? Say, my equation name is eq02, how do I than generate fitted values for the dependent variable from that equation? Thanks a lot in advance, much appreciated. :)

startz
Non-normality and collinearity are NOT problems!
Posts: 3138
Joined: Wed Sep 17, 2008 2:25 pm

Re: Coputation of fitted values

Postby startz » Thu Sep 21, 2017 10:08 am

oksanakim wrote:Thank you Startz! Do you suggest that the second-stage estimation will be incorrect? The reason I fell for the manual estimation is because the Eviews' built in option returns negative R-squared and some menaingless results, compared to standard OLS estimation. This is why I decided to try manual estimation. Is there any way to correct the standard errors? And can you please be more specific as to the sintax for fit? Say, my equation name is eq02, how do I than generate fitted values for the dependent variable from that equation? Thanks a lot in advance, much appreciated. :)

There is nothing at all wrong with a negative R-squared.

The fit command is documented in the help system.

It's fine to do 2SLS manually for fun, but the way to be sure that coefficients, standard errors, R-squared, etc. are correct is to see if your results match EViews. There's nothing to "fix" by doing it manually.

oksanakim
Posts: 35
Joined: Wed Apr 04, 2012 10:38 am

Re: Coputation of fitted values

Postby oksanakim » Thu Sep 21, 2017 10:17 am

Thank you again! I have a related quesiton/observation. I also estimated Heckit in Eviews and then did the same manually: I estimated the first-stage probit model, then computed Inverse mills ratio using one of the commands provided in the forum earlier, and then used it as a dependent variables in the second stage estimation with OLS. The results of the manual derivation versus Heckit are overwhelmingly different: in Heckit the coefficients of interest are insignificant, whereas in the manual derivations they are highly significant. The program I used to compute inverse mills ratio was:

eq01.makeresid ordinary
eq01.makeresid(g) general
eq01.fit yprob
series imills2 = general*(1-yprob)/ordinary

In the previous versions of Eviwes, there was no Heckit option and I used to compute Imills ratio manually using the command above. But now what's wrong with the manual estimation and why are the two so different? This is striking. I can provide an output for the two estimations - manual and heckit - if you are interested. Thanks a lot.

startz
Non-normality and collinearity are NOT problems!
Posts: 3138
Joined: Wed Sep 17, 2008 2:25 pm

Re: Coputation of fitted values

Postby startz » Thu Sep 21, 2017 10:20 am

I'm afraid I haven't done a Heckit in a long time.

oksanakim
Posts: 35
Joined: Wed Apr 04, 2012 10:38 am

Re: Coputation of fitted values

Postby oksanakim » Thu Sep 21, 2017 10:21 am

I see... Is the command to compute the Inverse Mills raito at least correct? Thanks Startz.

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

Re: Coputation of fitted values

Postby EViews Gareth » Thu Sep 21, 2017 10:45 am

Somewhat obvious question - but when using the built in method of estimation, did you use two-step or ML?
Follow us on Twitter @IHSEViews

oksanakim
Posts: 35
Joined: Wed Apr 04, 2012 10:38 am

Re: Coputation of fitted values

Postby oksanakim » Thu Sep 21, 2017 10:58 am

I used Heckam two-step option.

oksanakim
Posts: 35
Joined: Wed Apr 04, 2012 10:38 am

Re: Coputation of fitted values

Postby oksanakim » Thu Sep 21, 2017 11:00 am

I also wonder why a coefficient on Inverse Mills ratio is not reported when Heckit is used. It's kind of a big deal to discuss whether or not it is significant, at least for academic publications. Thank you.

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

Re: Coputation of fitted values

Postby EViews Gareth » Thu Sep 21, 2017 11:45 am

It was our view that the literature had moved away from the two-step model, and only included it for completeness. There's really no reason to estimate using the two-step method other than as a teaching tool (same argument as two-stage least squares).


Having said that - no idea why your estimation is not matching the built in. Without seeing exactly what you did, it is hard to say.

Having said that, here's an example of manual two-step compared with built in using the MROZ workfile.

Code: Select all

smpl @all

equation select.binary inlf age age^2 faminc kids educ
select.fit(i) xbhat

series imills = @dnorm(xbhat)/@cnorm(xbhat)
series delt = imills*(imills+xbhat)

smpl if inlf = 1
equation response.ls wage exper exper^2 educ city imills
scalar sigma = @sqrt(response.@ssr/response.@regobs + @mean(delt)*response.c(5)*response.c(5))
scalar rho = response.c(5)/(sigma)

group wg exper exper^2 educ city imills
matrix w = @convert(wg)

group zg age age^2 faminc kids educ
matrix z = @convert(zg)

stom(delt, dvec)
sym delta = @makediagonal(dvec)
sym mid1 = @identity(@rows(delta)) -rho*rho*delta
sym wrw = @transpose(w)*mid1*w

sym V = select.@coefcov
sym Q = @transpose(w)*delta*z*v*@transpose(z)*delta*w*rho*rho

sym invww = @inverse(@transpose(w)*w)

sym cov = sigma*sigma*invww*(wrw + q)*invww

smpl @all

equation builtin.HECKIT(2STEP) WAGE EXPER EXPER^2 EDUC CITY @ INLF AGE AGE^2 FAMINC KIDS EDUC

show response
show builtin
Follow us on Twitter @IHSEViews

oksanakim
Posts: 35
Joined: Wed Apr 04, 2012 10:38 am

Re: Coputation of fitted values

Postby oksanakim » Thu Sep 21, 2017 11:58 am

Not really, these models are widely used in academic publications, some streams of research assume they are used no matter what. Thank you for the example of the program. Please confirm, is the below program to compute Inverse Mills ratio correct? Thanks a bunch :D

eq01.makeresid ordinary
eq01.makeresid(g) general
eq01.fit yprob
series imills2 = general*(1-yprob)/ordinary

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

Re: Coputation of fitted values

Postby EViews Gareth » Thu Sep 21, 2017 12:06 pm

Heckman selection is widely used - but aren't most estimated with the superior ML method rather than 2Step?

I'm not sure if your calculation is correct, but I'm pretty sure the one in the code I posted is, and matches the wikipedia definition of the ratio.
https://en.wikipedia.org/wiki/Mills_ratio
Follow us on Twitter @IHSEViews

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

Re: Coputation of fitted values

Postby EViews Gareth » Thu Sep 21, 2017 12:15 pm

Thinking about it a bit, yes your code will compute it correctly too.

You can confirm this by adding this code to the bottom of my code:

Code: Select all

select.makeresid ordinary
select.makeresid(g) general
select.fit yprob
series imills2 = general*(1-yprob)/ordinary
show imills2 imills
Follow us on Twitter @IHSEViews

oksanakim
Posts: 35
Joined: Wed Apr 04, 2012 10:38 am

Re: Coputation of fitted values

Postby oksanakim » Thu Sep 21, 2017 12:15 pm

Thank you, the two codes return the same results for Imills series.


Return to “Estimation”

Who is online

Users browsing this forum: No registered users and 8 guests