Getting Wrong Answer

For econometric discussions not necessarily related to EViews.

Moderators: EViews Gareth, EViews Moderator

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

Getting Wrong Answer

Postby diggetybo » Wed Nov 18, 2015 10:59 am

Hello,

I wrote my own code to solve for probit marginal effects, given certain scenarios. (yes, I know there are already functional ones out there written by the eviews proffessionals) So why did I reinvent the wheel? I just felt very inept at the whole procedure, and thought if I could code it from scratch I would learn a lot. I certainly improved my coding ability, but sadly my answer doesn't match the books. Have a look:

Code: Select all

equation eq01.binary(n=d) inlf c educ age nwifeinc exper expersq kidslt6 kidsge6 group derivs for %i c educ age nwifeinc exper expersq derivs.add {%i} next for !i = 2 to derivs.@count %c = @str(eq01.@coef(!i)) %v = derivs.@seriesname(!i) %m = @str(@mean({%v})) if !i < derivs.@count then %spec = %spec+%c+"*"+%m+ " + " endif if !i = derivs.@count then %spec = %spec+%c+"*"+%m endif next %discrete_1 = "kidslt6" %discrete_2 = "kidsge6" %disvar1 = @str(eq01.@coef(7)*0) %disvar2 = @str(eq01.@coef(8)*1) %spec = %spec+ "+" + %disvar1+"+" + %disvar2 %intercept = @str(eq01.@coef(1)) %spec = %spec+"+"+%intercept scalar prob_estimate = @cnorm({%spec})
According to the book the answer from @cnorm should come out to: .707 when kidslt6=0, and .373 when kidslt6=1. I have attached the workfile for reference. All you have to do is copy and paste the above code into a program and it will run. However, it's not quite right somehow. This code evaluates @cnorm({%spec}) to be .655. Any tips would be much appreciated.
mroz.wf1
(144.86 KiB) Downloaded 357 times
Thanks for reading

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

Re: Getting Wrong Answer

Postby EViews Gareth » Wed Nov 18, 2015 11:08 am

Which book/page?

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

Re: Getting Wrong Answer

Postby diggetybo » Wed Nov 18, 2015 11:20 am

It's the Wooldridge (2006) Introductory Econometrics: A Modern Approach 4e. Page: 586. Chapter 17, example: 17.1

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

Re: Getting Wrong Answer

Postby EViews Gareth » Wed Nov 18, 2015 12:10 pm

I believe you are calculating it correctly.

Note that (at least in my 5th edition), Jeff doesn't use the exact averages of the series, he uses the following numbers:

nwifeinc = 20.13
educ = 12.3
exper = 10.6
age = 42.5

Using those numbers rather than the exact averages will get you closer to his published result. But note he doesn't state what he uses for exper^2 (but you can assume he roughly took the 10.6 and squared it). Without knowing exactly which value he uses for exper^2, I don't think it is possible to exactly replicate his result.

Your program seemed to have excessive use of string variables, by the way.

Code: Select all

equation eq01.binary(n=d) inlf c educ age nwifeinc exper expersq kidslt6 kidsge6 group derivs for %i c educ age nwifeinc exper expersq derivs.add {%i} next !spec = 0 for !i = 2 to derivs.@count !c = eq01.@coef(!i) %v = derivs.@seriesname(!i) !m = @mean({%v}) !spec = !spec+!c*!m next !disvar1 = eq01.@coef(7)*0 !disvar2 = eq01.@coef(8)*1 !spec = !spec+ !disvar1+!disvar2 !intercept = eq01.@coef(1) !spec = !spec+!intercept scalar prob_estimate = @cnorm(!spec)

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

Re: Getting Wrong Answer

Postby EViews Gareth » Wed Nov 18, 2015 12:28 pm

Also note the last line from Jeff:
Note that the calculations provided here, which use coefficients mostly rounded to the third decimal place, will differ somewhat from calculations obtained within a statistical package - which would be subject to less rounding error).

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

Re: Getting Wrong Answer

Postby diggetybo » Wed Nov 18, 2015 9:40 pm

Hey,

Thanks for the fine-tuning on the code, it's much better this way. So it all comes down to cumulative rounding error. If you look at it that way, for once I'm right and Jeff is wrong. Muaahahahahaha.

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

Re: Getting Wrong Answer

Postby EViews Gareth » Wed Nov 18, 2015 10:56 pm

Plus a difference in the interpretation of the value of exper^2


Return to “Econometric Discussions”

Who is online

Users browsing this forum: No registered users and 2 guests