Page 1 of 1

Getting Wrong Answer

Posted: Wed Nov 18, 2015 10:59 am
by diggetybo
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 362 times
Thanks for reading

Re: Getting Wrong Answer

Posted: Wed Nov 18, 2015 11:08 am
by EViews Gareth
Which book/page?

Re: Getting Wrong Answer

Posted: Wed Nov 18, 2015 11:20 am
by diggetybo
It's the Wooldridge (2006) Introductory Econometrics: A Modern Approach 4e. Page: 586. Chapter 17, example: 17.1

Re: Getting Wrong Answer

Posted: Wed Nov 18, 2015 12:10 pm
by EViews Gareth
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)

Re: Getting Wrong Answer

Posted: Wed Nov 18, 2015 12:28 pm
by EViews Gareth
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).

Re: Getting Wrong Answer

Posted: Wed Nov 18, 2015 9:40 pm
by diggetybo
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.

Re: Getting Wrong Answer

Posted: Wed Nov 18, 2015 10:56 pm
by EViews Gareth
Plus a difference in the interpretation of the value of exper^2