[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

From |
<jrfranke@illinois.edu> |

To |
statalist@hsphsun2.harvard.edu |

Subject |
st: marginal effects and standard errors in count regressions |

Date |
Mon, 16 Feb 2009 10:08:41 -0600 (CST) |

Dear listers, I think I had a problem with my email, so I'm trying again (if I am posting this message twice I appologize). I got some great help here a while back with computing marginal effects for a count regression with x1 and x1^2 terms using the "poisson" command (I expect a nonlinear effect of x1). Now, I'm having difficulty with computing the standard errors of the marginal effect and the resulting Z-statistics. Ultimately, I need to be able to compute the effects of interaction and squared terms (and Z-stats for significance) as in Norton, Wang, and Ai(see http://www.unc.edu/%7Eenorton/NortonWangAi.pdf). First, I'm trying to reproduce the results for an individual term (not intereacted or raised to a power). I'm not sure if I've miss-coded the below (or perhaps I miss-calculated a derivative), or if there are some assumptions/shortcuts underlying -mfx-, -margeff-, -nlcom-, and -predictnl- commands (perhaps with regard to the delta method) that lead to inconsistencies, particularly for the standard errors. I do realize that -mfx- cacluates marginal effects at the mean, whereas -margeff- by default calculates the mean marginal effect. Thanks in advance for any insights you can provide! Jason Franken Code follows: * Example (note: south & smsa are binary dummies): sysuse nlsw88, clear g g2=grade^2 poisson wage grade g2 tenure hours south smsa, r mfx margeff, dummies(south smsa) replace* Attempt to reproduce -mfx- & -margeff- results for marginal effect & standard errors for tenure: poisson wage grade g2 tenure hours south smsa, r matrix V = get(VCE) egen grade_bar = mean(grade) egen g2_bar = mean(g2) egen tenure_bar = mean(tenure) egen hours_bar = mean(hours) egen south_bar = mean(south) egen smsa_bar = mean(smsa) gen south1 = 1 gen smsa1 = 1 gen eBXbar = exp(_b[grade]*grade_bar + _b[g2]*g2_bar + _b[tenure]*tenure_bar + _b[hours]*hours_bar + _b[south]*south_bar + _b[smsa]*smsa_bar + _b[_cons]) gen eBXbar1 = exp(_b[grade]*grade_bar + _b[g2]*g2_bar + _b[tenure]*tenure_bar + _b[hours]*hours_bar + _b[south]*south1 + _b[smsa]*smsa1 + _b[_cons]) gen eBX = exp(_b[grade]*grade + _b[g2]*g2 + _b[tenure]*tenure + _b[hours]*hours + _b[south]*south + _b[smsa]*smsa + _b[_cons])*REPRODUCE THE -mfx- RESULT: *Marginal effect is derivative of E[y|x] w.r.t tenure: gen mf_tenureAtMean = _b[tenure]*eBXbar gen mf_tenureAtMean1 = _b[tenure]*eBXbar1 *Standard error of marginal effect is (G×V×G')^0.5, where G is the derivative of E[y|x] w.r.t tenure: gen G_tenure_bar = eBXbar + (_b[tenure]*eBXbar*eBXbar) matrix list V gen SE_tenureAtMean = (G_tenure_bar*(5.496e-06)*G_tenure_bar)^0.5 sum mf_tenureAtMean SE_tenureAtMean *THE ABOVE ARE "IN THE BALLPARK" BUT NOT EXACTLY THE -mfx- RESULT.*ANOTHER OPTION IS TO USE -nlcom- AND -predictnl- COMMANDS - THESE ALSO DO NOT REPRODUCE -mfx-. nlcom (mf_tenureAtMean_nlcom: _b[tenure]*eBXbar) predictnl mf_tenureAtMean_predictnl = _b[tenure]*eBXbar, se(SE_tenureAtMean_predictnl) sum mf_tenureAtMean_predictnl SE_tenureAtMean_predictnl*REPRODUCE THE -margeff- RESULT: *Marginal effect is derivative of E[y|x] w.r.t tenure: gen mf_tenure = _b[tenure]*eBX *Standard error of marginal effect is (G×V×G')^0.5, where G is the derivative of E[y|x] w.r.t tenure: gen G_tenure = eBX + (_b[tenure]*eBX*eBX) egen MeanG_tenure = mean(G_tenure) gen MeanSE_tenure = (MeanG_tenure*(5.496e-06)*MeanG_tenure)^0.5 gen SE_tenure = (G_tenure*(5.496e-06)*G_tenure)^0.5 sum mf_tenure SE_tenure MeanSE_tenure *THE ABOVE EXACTLY REPRODUCES THE MARGINAL EFFECT (BUT NOT ITS STANDARD ERROR) FOR THE -margeff- COMMAND. *AGAIN, WE CAN TRY THE -predictnl- COMMAND - HERE, THE MARGINAL EFFECT (BUT NOT ITS STANDARD ERROR) IS IDENTICAL TO THE -margeff- RESULT. predictnl mf_tenure_predictnl = _b[tenure]*eBX, se(SE_tenure_predictnl) sum mf_tenure_predictnl SE_tenure_predictnl * * For searches and help try: * http://www.stata.com/help.cgi?search * http://www.stata.com/support/statalist/faq * http://www.ats.ucla.edu/stat/stata/

**Follow-Ups**:**st: AW: marginal effects and standard errors in count regressions***From:*"Martin Weiss" <martin.weiss1@gmx.de>

- Prev by Date:
**Re: st: Tiao-Goldberger test** - Next by Date:
**st: double hurlde models?** - Previous by thread:
**st: regress analysis** - Next by thread:
**st: AW: marginal effects and standard errors in count regressions** - Index(es):

© Copyright 1996–2014 StataCorp LP | Terms of use | Privacy | Contact us | What's new | Site index |