Poisson regression
6.6 Marginal effects, elasticities, and discrete change
6.6.1 Marginal effects for Poisson and negative binomial effects models
Essentially, a marginal effect is used to understand the relationship of an esti-mated predictor and its predicted probability, with other predictor values held
at a specified value, usually at their means or medians. Specifically, marginal effects are used to quantify the relationship of how the probability of an outcome changes given a unit (or units) change in the value of the predictor.
Marginal effects can also be thought of as the instantaneous rate of change in the probability of an outcome given a specific change of value for a predictor, holding other predictor values at their mean (or other) values. This notion stems directly from the nature of a slope (i.e. a rate of change), and is expressed in terms of a partial derivative. Recall that regression coefficients, βk, are themselves slopes, with k indicating any of the individual predictor coefficents in a model. In fact, marginal effects are identical in value to the coefficients or slopes given in ordinary least squares regression. This same identity does not hold for non-linear models, such as Poisson and negative binomial regression.
We shall define two varieties or interpretations of marginal effect. The first is understood with the marginal effect being taken at the sample means of the model predictors. This interpretation has probably enjoyed the most popularity.
The second interpretation with respect to count models is understanding the marginal effect taken at the average of the predicted counts in the model. When related to a binary predictor, the average marginal effect is also termed a partial effect, although some statisticians allow the term to be used for any form of predictor. We shall examine each of these two interpretations, beginning with the marginal effect at mean approach.
Marginal effects at the mean
Being essentially non-linear models, the marginal effects of a continuous pre-dictor in a Poisson or negative binomial model vary across observations. The logic of the effect for a specific continuous predictor can be given as:
∂E(yi|xi)
∂xi = ∂µi
∂xi
(6.44)
= ∂exiβ
∂xi
(6.45)
= ∂exiβ
∂xiβ
∂xiβ
∂xi (6.46)
= exiββk= exp(xiβ)βk (6.47) For any continuous predictor in a Poisson or negative binomial (NB2) model, the marginal effect may be expressed as
∂E(yi|xi)
∂xik
= E (yi|xi) βk= exp(xiβk)βk (6.48)
Using the derivative nature of the marginal effect, I shall demonstrate how to calculate it employing a simple Poisson example. Using the German health data, rwm5yr, with the number of visits a patient makes to a doctor during a given year as the response, and work status and age as predictors, the marginal effect of age may be calculated using the following logic. First we model the data using a Poisson regression, but not displaying header information.
Table 6.18 R: Marginal effects
rwm <- rwm5yr
rwm1 <- glm(docvis ~ outwork + age, family=poisson, data=rwm) meanout <- mean(rwm$outwork)
meanage <- mean(rwm$age)
xb <- coef(rwm1)[1] + coef(rwm1)[2]*meanout + coef(rwm1)[3]
*meanage
dfdxb <- exp(xb) * coef(rwm1)[3]
mean(dfdxb) # answer = 0.06043214
. use rwm5yr
. keep docvis outwork age
. glm docvis outwork age, nolog fam(poi) nohead
---docvis | Coef. Std. Err. z P>|z| [95% Conf. Interval]
---+---outwork | .3256733 .0083798 38.86 0.000 .3092493 .3420973 age | .019931 .0003697 53.91 0.000 .0192064 .0206555 _cons | .124546 .0171297 7.27 0.000 .0909724 .1581197 ---. qui sum outwork /// summarize outwork
. qui replace outwork=r(mean) /// change outwork to its mean
. qui sum age /// summarize age
. qui replace age=r(mean) /// change age to its mean . predict xb, xb /// calculate linear predictor
on basis of mean values . gen dfdxb = exp(xb)*_b[age] /// exp(xb)*β
. l dfdxb in 1 /// display the ME
---dfdxb ---1. .0604319
---Stata’s margins command calculates the marginal effect at the mean of age by using the following command. Observe that the displayed value for age is identical to what we calculated by hand.
The marginal effect of age may be interpteted as: at the mean values of the predictors in the model (sample mean), the number of visits to the doctor increases by 0.06, or 6%, for every year increase in age.
. margins, dydx(age) atmeans
Conditional marginal effects Number of obs = 19609 Model VCE : OIM
Expression : Predicted number of events, predict() dy/dx w.r.t. : age
at : outwork = .3439237 (mean)
age = 43.78566 (mean)
---| Delta-method
| dy/dx Std. Err. z P>|z| [95% Conf. Interval]
----+---age | .0604319 .001097 55.09 0.000 .0582818 .062582
---Average marginal effects
Marginal effects can also be taken as average marginal effects, calculated as βˆky¯
The command to calculate the average marginal effect is:
R
mean(rwm$docvis) * coef(rwm1)[3]
age 0.0633046
. margins, dydx(age)
Average marginal effects Number of obs = 19609 Model VCE : OIM
Expression : Predicted mean docvis, predict() dy/dx w.r.t. : age
---| Delta-method
| dy/dx Std. Err. z P>|z| [95% Conf. Interval]
----+---age | .0633046 .0012013 52.70 0.000 .0609502 .065659
---The average marginal effect for age specifies that, for each additional year of age, there are an average of 0.0633 additional visits to the doctor. With the coefficient of age given in the coefficient table above as 0.019931, and the mean of docvis as 3.176195, we may apply the formula to calculate the average marginal effect by hand.
. di 3.176195*.019931 .06330474
The calculated value is identical to the value displayed in the results. Also note that the standard error is calculated using the delta method.
Confidence intervals are generated as:
. di.0633046 -- 1.96*.0012013 .06095005
. di.0633046 + 1.96 *.0012013 .06565915
Elasticities
Elasticities are commonly used in econometrics and relate to percentages of change. Elasticities are defined as ME∗x/y, where ME is the interpretation of marginal effects defined earlier, x is the predictor and y the response. Continuing the example we have been using, the elasticity may be interpreted as: a 1%
increase in age is associated with a 0.873% increase in visits to the doctor.
R: Elasticity
se1 <- mean(dfdxb) mage <- mean(rwm5yr$age) se1 * mage/3.032
[1] 0.8727114
. margins, eyex(age) atmeans noatlegend
Conditional marginal effects Number of obs = 19609 Model VCE : OIM
Expression : Predicted number of events, predict() ey/ex w.r.t. : age
at : outwork = .3439237 (mean)
age = 43.78566 (mean)
---| Delta-method
| ey/ex Std. Err. z P>|z| [95% Conf. Interval]
----+---age | .8726901 .0161868 53.91 0.000 .8409646 .9044155
---Here x is 43.786 and y is the value of the fit at age 43.786, or 3.032. Given the marginal effect at the mean as calculated earlier, 0.604319, we have (with rounding error)
. di.0604319 * 43.78566 /3.032 .87270799
which is the same value as given in the output.
A semi-elasticity may be calculated as well. It may be interpreted as: for every one year increase in age, there is a 2% increase in visits to the doc-tor. If this interpretation appears familiar, it should. Owing to the exponen-tial nature of the Poisson and negative binomial mean, the Poisson/negative binomial coefficient is a semi-elasticity. This identity does not occur with NB-C, or with models in which the mean value is not exponential, e.g. µ= exp(xβ).
R: Semi-elasticity
se1/3.032 [1] 0.01993144
. margins, eydx(age) atmeans noatlegend
Conditional marginal effects Number of obs = 19609 Model VCE : OIM
Expression : Predicted mean docvis, predict() ey/dx w.r.t. : age
---| Delta-method
| ey/dx Std. Err. z P>|z| [95% Conf. Interval]
----+---age | .019931 .0003697 53.91 0.000 .0192064 .0206555
---This is the same value that we calculated for age in the initial Poisson model.
Exponentiating produces: exp(0.019931)= 1.0201309.
Elasticities may also be calculated for average marginal effects. The inter-pretations are analogous to the relationship of the marginal effects at mean and elasticities we defined above. Note that the Poisson/NB-semi-elasticity is only interpreted “at the mean.”
6.6.2 Discrete change for Poisson and negative binomial models