# Re: st: mfx and margeff calculations

 From "Austin Nichols" To statalist@hsphsun2.harvard.edu Subject Re: st: mfx and margeff calculations Date Fri, 28 Mar 2008 21:35:16 -0400

```Martin Watts <Martin.Watts@newcastle.edu.au>:
As pointed out in
http://www.stata.com/statalist/archive/2008-03/msg00652.html
how "the marginal effect" is calculated depends on what marginal
effect you mean.

But yes, when all the indicators for a set of k-1 regressors from a
set of k mutually exclusive exhaustive indicators are set to zero, you
have the prediction for the excluded group.  If computing a marginal
effect of age, presumably you would want to compare the excluded group
to the next higher age range, and that age range to the next highest,
and so on.  If you are using a marginal effects calculation that
leaves other variables at their observed values, or sets all to their
mean values, you are getting entirely the wrong answer.

webuse nhanes2, clear
g age2029=agegrp==1
g age3039=agegrp==2
g age4049=agegrp==3
g age5059=agegrp==4
g age6069=agegrp==5
g age70up=agegrp==6
g bmi=wei/hei^2*1e4
probit diab bmi age30-age70 [pw=fin], cl(psu)
preserve
foreach v of varlist age20-age60 {
qui replace `v'=0
}
predict pr20
forv i=30(10)70 {
qui replace age`i'=1
qui replace age`=`i'-10'=0
predict pr`i'
su age20-age60
}
su pr?? [aw=fin], sep(0)
loc v=1
forv i=30(10)70 {
su pr`i' [aw=fin], meanonly
loc m1=r(mean)
su pr`=`i'-10' [aw=fin], meanonly
loc diff=`m1'-r(mean)
di as res "Marginal effect of increase in age "_c
di "category from `: lab (agegrp) `v++'' to " _c
di "`: lab (agegrp) `v'' : " `diff'
}
restore

On Fri, Mar 28, 2008 at 7:25 PM, Martin Watts
<Martin.Watts@newcastle.edu.au> wrote:
> Herewith possibly a silly question. Consider say a probit with a series of variables representing age ranges, with obviously a default age range, not included in the estimation. How is say margeff calculated for say AGE3544? Presumably without any consideration of the fact that an individual can only occupy one age range.
>  The calculation can be undertaken manually, so that when AGE3544 is set to 1, the others are all zero, but what about when AGE3544 is set to zero? Obviously the default age range kicks in.
>
>  Is that the desirable calculation??
>
>  Or have I got it all wrong?
>  Thanks.
>
*
*   For searches and help try:
*   http://www.stata.com/support/faqs/res/findit.html
*   http://www.stata.com/support/statalist/faq
*   http://www.ats.ucla.edu/stat/stata/
```