# Re: st: count regression with product & power terms

 From Austin Nichols To statalist@hsphsun2.harvard.edu Subject Re: st: count regression with product & power terms Date Tue, 3 Feb 2009 15:42:11 -0500

```Jason Franken <jrfranke@illinois.edu>:
There are not marginal effects for both x1 and x1squared; there is
only a marginal effect for x1, since you cannot vary x1 without also
varying x1squared.  I think you want something like this:

sysuse nlsw88, clear
unab x: tenure hours south smsa
poisson wage grade g2 `x', r
predict double hat
la var amfx "Mean Marginal Effect"
bys grade: replace amfx=. if _n>1
drop hat mf
foreach v of local x {
ren `v' was`v'
su was`v' if e(sample), meanonly
g double `v'=r(mean)
}
predict double hat
foreach v of local x {
drop `v'
ren was`v' `v'
}
bys grade (amfx): replace mfxa=. if _n>1
drop hat
la var mfxa "Marginal Effect at Mean"

On Tue, Feb 3, 2009 at 1:54 PM,  <jrfranke@illinois.edu> wrote:
> I'm running a count regression with x1 and x1^2 terms using the "poisson" command (I expect a nonlinear effect of x1), and want to compute marginal effects.
>
...
>  *FOLLOWING SHOULD GIVE TRUE MARGINAL EFFECT FOR "x1" ...
>  *for the average of marginal effects for all observations (like "margeff"):
>   gen mf_x1 = (_b[x1]+(2*_b[x1squared]*x1))*eBX
>    sum mf_x1
>  *for the marginal effect at mean values of other explanatory variables (like "mfx"):
>   gen mf_rpMEAN = (_b[x1]+(2*_b[x1squared]*x1bar))*eBXbar
>    list mf_rpMEAN
>
>  *FOLLOWING SHOULD GIVE TRUE MARGINAL EFFECT FOR "x1squared".
>  *for the average of marginal effects for all observations (like "margeff"):
>   gen mf_x1squared = (2*_b[x1squared]*eBX) + (((_b[x1]+(2*_b[x1squared]*x1))^2)*eBX)
>    sum mf_x1squared
>  *for the marginal effect at mean values of other explanatory variables (like "mfx"):
>   gen mf_x1squaredMEAN = (2*_b[x1squared]*eBXbar) + (((_b[x1]+(2*_b[x1squared]*x1bar))^2)*eBXbar)
>    list mf_x1squaredMEAN
*
*   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/
```