On Thursday, Puja asked:
> How does the dmlogit2 command calculate marginal effects for dummy
> variables - as an infinitisimally small change or a unit/discrete change
> from 0 to 1?
Yes, it treats all variables as continuous. We can confirm this by using
-mfx- with the -nodiscrete- option:
clear
sysuse auto
set seed 123
gen dum=uniform()>0.4
mlogit rep dis dum, nolog
mfx, predict(outcome(5) p) varlist(dum)
mfx, predict(outcome(5) p) nodiscrete
dmlogit2 rep dis dum
To compute the marginal effect of a dummy variable by hand is done as
follows:
clear
sysuse auto
set seed 123
gen dum=uniform()>0.4
mlogit rep dis dum, nolog
mfx, predict(outcome(5) p) nose
sum dis if e(sample)
replace dis=r(mean)
sum dum if e(sample)
replace dum=r(mean)
predict y, outcome(5) p
list y in 1
replace dum=1
predict double p5_1, outcome(5) p
replace dum=0
predict double p5_0, outcome(5) p
di "marginal effect of dum = " p5_1-p5_0
There is an example using this technique in the FAQ:
http://www.stata.com/support/faqs/stat/mfx_svy.html
Getting the standard error of the marginal effect by hand is trickier.
With some effort we can use -nlcom- to do this, because it can compute
the standard error of any function of the coefficients of the model by
the delta method. Most of the effort in this approach is figuring out
the actual formula for the marginal effect. The formula for the
predicted probability is in the manual [R] mlogit, and using that we
have the following:
clear
sysuse auto
set seed 123
gen dum=uniform()>0.4
drop if rep==1
mlogit rep dum, nolog
mfx, predict(outcome(5) p)
replace dum=0
predict p5_0,outcome(5) p
gen myp5_0 = exp([5]_b[_cons])/ /*
*/ (1+exp([2]_b[_cons])+ /*
*/ exp([4]_b[_cons])+ /*
*/ exp([5]_b[_cons]))
sum myp5_0 p5_0
replace dum=1
predict p5_1,outcome(5) p
gen myp5_1 = exp([5]_b[_cons]+[5]_b[dum])/ /*
*/ (1+exp([2]_b[_cons]+[2]_b[dum])+ /*
*/ exp([4]_b[_cons]+[4]_b[dum])+ /*
*/ exp([5]_b[_cons]+[5]_b[dum]))
sum myp5_1 p5_1
di "marginal effect of dum = " p5_1-p5_0
nlcom exp([5]_b[_cons]+[5]_b[dum])/ /*
*/ (1+exp([2]_b[_cons]+[2]_b[dum])+ /*
*/ exp([4]_b[_cons]+[4]_b[dum])+ /*
*/ exp([5]_b[_cons]+[5]_b[dum])) /*
*/ - exp([5]_b[_cons])/ /*
*/ (1+exp([2]_b[_cons])+ /*
*/ exp([4]_b[_cons])+ /*
*/ exp([5]_b[_cons]))
--May
[email protected]
*
* 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/