Notice: On April 23, 2014, Statalist moved from an email list to a forum, based at statalist.org.
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: st: Margins in STATA 12 - how to use at () for dichotomous variables?
From
Joerg Luedicke <[email protected]>
To
[email protected]
Subject
Re: st: Margins in STATA 12 - how to use at () for dichotomous variables?
Date
Fri, 14 Dec 2012 11:05:24 -0500
With your first option, you are calculating marginal effects for
gender=1. Say gender is coded 0 for males and 1 for females, you are
computing marginal effects for females. With your second option you
are fixing gender at its mean, which may not be very meaningful and it
may be better to not use the -at()- option here at all but instead
average the predictions over men and women. Either way, it is
obviously not the same as doing the predictions for either men or
women. Consider the following example:
//Some toy data (I use some modified code from Joseph Hilbe
(http://www.stata.com/statalist/archive/2011-06/msg00183.html)
clear
set obs `=1e4'
set seed 1234
gen x1 = rnormal()
gen gender = runiform()>.5
//Count component
gen xb = 2 + 0.5*x1 - 0.5*gender
gen a = .5
gen ia = 1/a
gen exb = exp(xb)
gen xg = rgamma(ia, a)
gen xbg = exb * xg
gen nby = rpoisson(xbg)
//Binary component
gen pi =1/(1+exp(-(0.5*x1 + 0.5*gender + 0.2)))
gen bernoulli = runiform()>pi
gen zy = bernoulli*nby
rename zy y
//Model fit
zinb y x1 gender, inflate(x1 gender)
//OP's -margins- statements
margins, dydx(x1) at(gender=1)
margins, dydx(x1) at((mean) gender)
//Now consider the following which is similar to your second statement:
sum gender
margins, dydx(x1) at(gender=.4983)
//And compare it to the following, where the marginal effects are
averaged over men and women:
margins, dydx(x1)
Joerg
On Thu, Dec 13, 2012 at 11:44 PM, Neeraj Iyer <[email protected]> wrote:
> Hello Statalisters,
>
> I am running a zero-inflated negative binomial model with 8
> predictors, 4 of which are dichotomous. For marginal analysis, I am
> setting the continuous variables at means, but did not know how to
> specify the at () function for dichotomous variables. Can someone
> shed some light on this issue please, thank you.
>
> I have considered 3 options:
>
> 1) margins, dydx (varlist) at (gender=1)
> 2) margins, dydx (varlist) at ((mean) gender)
>
> I reckon that the second option might be influenced by the proportion
> of one gender over the other, but wont it be the same even for the
> first choice?
>
> Regards,
> Neeraj
> *
> * For searches and help try:
> * http://www.stata.com/help.cgi?search
> * http://www.stata.com/support/faqs/resources/statalist-faq/
> * http://www.ats.ucla.edu/stat/stata/
*
* For searches and help try:
* http://www.stata.com/help.cgi?search
* http://www.stata.com/support/faqs/resources/statalist-faq/
* http://www.ats.ucla.edu/stat/stata/