20  IV in Poisson with Fixed Effects

Poisson regression specifies the conditional mean as an exponential function: \[E(y \mid \mathbf{x}) = \exp(\mathbf{x}\boldsymbol{\beta})\]

As a quasi-maximum likelihood estimator (QMLE), Poisson regression requires only that the conditional mean is correctly specified; the true count distribution does not need to follow a Poisson distribution, and standard errors are easily made robust to arbitrary overdispersion or heteroskedasticity.

However, when an explanatory variable is endogenous—correlated with unobserved omitted factors—standard linear two-stage least squares (2SLS) intuition fails. Because the conditional mean is nonlinear, unobserved confounders enter multiplicatively inside the exponential function.

This chapter covers:

  1. Why linear 2SLS intuition fails in nonlinear exponential models.
  2. The control function approach for continuous vs. binary endogenous variables.
  3. Terza’s exact correction (Terza 1998) and its profile-likelihood implementation.
  4. Generalized residuals as a first-order local approximation, logit response residuals, and the Mundlak device for panel fixed effects (Lin and Wooldridge 2019).
  5. Why applied econometrics generally recommends the generalized residual approach over the exact Terza correction.
  6. Multiplicative-moment GMM (Mullahy 1997) and quasi-differencing for panel fixed effects.
  7. Why the exogeneity test should not be used to choose between the naive and control-function models (Guggenberger 2010a).
  8. Step-by-step implementation demos in Julia (Panelest.jl) and Stata (ppmlhdfe).

20.1 The model and setup

Let \(y_1\) denote the count outcome, \(y_2\) the endogenous explanatory variable, and \(\mathbf{z} = (\mathbf{z}_1, \mathbf{z}_2)\) the vector of exogenous variables (\(\mathbf{z}_1\) included in the structural equation, \(\mathbf{z}_2\) excluded instruments).

The structural conditional mean is: \[E(y_1 \mid \mathbf{z}_1, y_2, c_1) = \exp(\mathbf{z}_1\boldsymbol{\delta}_1 + \alpha_1 y_2 + c_1) \tag{20.1}\]

where \(c_1\) is an unobserved omitted variable correlated with \(y_2\). Our primary estimand of interest is \(\alpha_1\), the structural semi-elasticity of \(y_1\) with respect to \(y_2\).

20.1.1 Subscripts index equations

Following the simultaneous-equations convention of Wooldridge (2010) (ch. 18), subscripts index equations rather than individual variables:

  • Equation 1 (Structural equation): outcome \(y_1\), parameters \((\boldsymbol{\delta}_1, \alpha_1)\), unobserved error \(c_1\).
  • Equation 2 (Reduced-form equation): outcome \(y_2\), coefficients \(\boldsymbol{\pi}_2\), reduced-form error \(v_2\).
Role Linear IV Notation Nonlinear Notation Here Description
Outcome (the count) \(Y\) \(y_1\) Dependent variable in structural equation
Endogenous regressor \(W\) or \(D\) \(y_2\) Explanatory variable correlated with \(c_1\)
Excluded instrument \(Z\) \(\mathbf{z}_2\) Exogenous instrument excluded from Eq. 1
Included exogenous \(X\) \(\mathbf{z}_1\) Exogenous covariates included in Eq. 1
Reduced-form error \(V\) \(v_2\) Error from projecting \(y_2\) on \(\mathbf{z}\)
Structural unobservable \(U\) \(c_1\) Confounder correlated with \(y_2\)
Endogeneity parameter \(\rho\) \(\rho_1\) Projection coefficient: \(c_1 = \rho_1 v_2 + e_1\)

Two departures from Wooldridge’s notation are maintained for clarity:

  1. Wooldridge writes the coefficient on \(y_2\) as \(\gamma_1\); we write \(\alpha_1\) to align with standard treatment effect notation.
  2. Where Wooldridge writes \(\mathbf{x}_1\boldsymbol{\beta}_1\), we write \(\mathbf{z}_1\boldsymbol{\delta}_1 + \alpha_1 y_2\).

20.1.2 Fixed effects in the exponential model

Everything below absorbs fixed effects without comment, and it is worth saying once why that is allowed. Fixed-effects Poisson has no incidental parameters problem (Wooldridge 1999; Lin and Wooldridge 2019). With \(N \to \infty\) and \(T\) fixed, the unit effects enter multiplicatively, factor out of the score, and are conditioned out cleanly. The estimator of \(\boldsymbol{\beta}\) is consistent even though the number of unit parameters grows with the sample. Probit and logit have no such property, which is why the first stage of Section 20.3.4 needs the Mundlak device while the second stage does not.

The software follows from this. In Stata, xtpoisson, fe fits the conditional model, but the community standard is ppmlhdfe (Correia, Guimarães, and Zylkin 2020): it absorbs several dimensions of fixed effects at once, it is fast, it detects separated and singleton observations, and it recovers predicted values with the absorbed effects put back. In Julia, Panelest.jl provides fepois() for the same job, with feols() for the linear first stage.

Stata’s ivpoisson handles endogenous regressors, but it cannot absorb high-dimensional fixed effects. That is the practical reason the panel literature routes endogeneity through a control function rather than through a packaged IV command: the control function leaves the second stage as an ordinary FE Poisson regression, which ppmlhdfe and fepois already do well.


20.2 Control functions and GMM

20.2.1 A linear second stage: the control function is 2SLS

To see where the nonlinear complication begins, consider first the linear model: \[y_1 = \mathbf{z}_1\boldsymbol{\delta}_1 + \alpha_1 y_2 + \varepsilon_1, \qquad E(\mathbf{z}'\varepsilon_1) = \mathbf{0}\]

Two-stage least squares (2SLS) replaces \(y_2\) with its linear projection \(\hat{y}_2 = \mathbf{z}\hat{\boldsymbol{\pi}}_2\): \[y_1 = \mathbf{z}_1\boldsymbol{\delta}_1 + \alpha_1 \hat{y}_2 + (\varepsilon_1 + \alpha_1 \hat{v}_2)\] where \(\hat{v}_2 = y_2 - \hat{y}_2\) is the OLS residual.

Alternatively, the control function (CF) approach decomposes the structural error \(\varepsilon_1\) via a linear projection on the first-stage residual \(v_2\): \[\varepsilon_1 = \rho_1 v_2 + \eta_1\] where \(\rho_1 = \frac{\mathrm{Cov}(\varepsilon_1, v_2)}{\mathrm{Var}(v_2)}\). By the properties of linear projection, \(E(v_2 \eta_1) = 0\) and \(E(\mathbf{z}'\eta_1) = E(\mathbf{z}'\varepsilon_1) - \rho_1 E(\mathbf{z}'v_2) = \mathbf{0}\).

Plugging this into the structural equation yields the augmented regression: \[y_1 = \mathbf{z}_1\boldsymbol{\delta}_1 + \alpha_1 y_2 + \rho_1 \hat{v}_2 + \eta_1\]

By the Frisch–Waugh–Lovell (FWL) theorem, OLS estimation of this augmented regression produces an estimate \(\hat{\alpha}_1\) that is numerically identical to 2SLS. No additional distributional assumptions are required beyond the standard orthogonality condition \(E(\mathbf{z}'\varepsilon_1) = \mathbf{0}\).

20.2.2 A nonlinear second stage: the control function needs more than uncorrelatedness

When the conditional mean is exponential, this automatic numerical equivalence breaks down.

Substituting the error decomposition \(c_1 = \rho_1 v_2 + e_1\) into Equation 20.1 yields: \[\begin{aligned} E(y_1 \mid \mathbf{z}, y_2, v_2) &= E\left[ \exp(\mathbf{z}_1\boldsymbol{\delta}_1 + \alpha_1 y_2 + \rho_1 v_2 + e_1) \mid \mathbf{z}, y_2, v_2 \right] \\ &= \exp(\mathbf{z}_1\boldsymbol{\delta}_1 + \alpha_1 y_2 + \rho_1 v_2) \cdot E\left[ \exp(e_1) \mid \mathbf{z}, y_2, v_2 \right] \end{aligned} \tag{20.2}\]

For the augmented index \(\mathbf{z}_1\boldsymbol{\delta}_1 + \alpha_1 y_2 + \rho_1 v_2\) to correctly specify the conditional mean in a Poisson second stage, the remaining expectation factor must be strictly constant: \[E\left[ \exp(e_1) \mid \mathbf{z}, y_2, v_2 \right] = \text{constant}\]

This is why Wooldridge (2010) (sec. 18.5) normalizes \(E[\exp(e_1)] = 1\) rather than \(E(e_1) = 0\).

This condition restricts the conditional moment-generating function of \(e_1\) at a single point. Every moment of \(e_1\) enters it, so it is far stronger than the zero-covariance condition that suffices in the linear model. It is not, however, an independence condition. Independence of \(e_1\) from \((\mathbf{z}, v_2)\), together with \(v_2 \perp \mathbf{z}\), is a sufficient assumption that delivers it, and it is the assumption we maintain below because it is simple to state and is what the standard derivation uses. Any weaker restriction that holds \(E[\exp(e_1) \mid \mathbf{z}, y_2, v_2]\) constant would serve equally well.

Property Linear Model (OLS / 2SLS) Nonlinear Model (Poisson CF)
Second stage \(y_1 = \mathbf{z}_1\boldsymbol{\delta}_1 + \alpha_1 y_2 + \rho_1 \hat{v}_2\) \(y_1 \sim \text{Poisson}(\exp(\mathbf{z}_1\boldsymbol{\delta}_1 + \alpha_1 y_2 + \rho_1 \hat{v}_2))\)
CF vs. 2SLS/GMM Identical (by FWL theorem) Different (FWL does not hold)
Required assumption Uncorrelatedness: \(E(\mathbf{z}'\varepsilon_1) = \mathbf{0}\) Constant conditional exponential moment; sufficient: \(v_2 \perp \mathbf{z}\) and \(e_1 \perp (\mathbf{z}, v_2)\)
Second-stage standard errors Valid under \(H_0: \rho_1 = 0\) Invalid (must bootstrap generated regressor)
Endogeneity test \(t\)-statistic on \(\hat{v}_2 = 0\) (DWH test) \(t\)-statistic on \(\hat{v}_2 = 0\) (Variable addition test)

20.3 Estimators for endogenous regressors

20.3.1 Continuous \(y_2\): the linear reduced form holds

When \(y_2\) is continuous (e.g., hours worked, prices, expenditures), a linear reduced form with additive errors is natural: \[y_2 = \mathbf{z}\boldsymbol{\pi}_2 + v_2, \qquad c_1 = \rho_1 v_2 + e_1 \tag{20.3}\]

with \(v_2 \perp \mathbf{z}\) and \(e_1 \perp (\mathbf{z}, v_2)\). These are two separate restrictions and it is worth keeping them apart. Joint normality of \((c_1, v_2)\) delivers the second: \(e_1\) is the projection residual, and for jointly normal variables uncorrelated implies independent. It says nothing about the first. \(v_2 \perp \mathbf{z}\) is a restriction on the reduced form — the conditional distribution of \(v_2\) must not vary with \(\mathbf{z}\) — and a linear equation with a homoskedastic normal additive error satisfies it. Both hold here; neither is implied by the other. The structural conditional mean becomes: \[E(y_1 \mid \mathbf{z}_1, y_2, v_2) = \exp(\mathbf{z}_1\boldsymbol{\delta}_1 + \alpha_1 y_2 + \rho_1 v_2) \tag{20.4}\]

Estimation Procedure: 1. Step 1 (First Stage): Estimate the linear regression \(y_2 = \mathbf{z}\boldsymbol{\pi}_2 + v_2\) by OLS (or with fixed effects absorbed) and compute residuals \(\hat{v}_2 = y_2 - \mathbf{z}\hat{\boldsymbol{\pi}}_2\). 2. Step 2 (Second Stage): Estimate Poisson QMLE with \(y_2\) and \(\hat{v}_2\) entering simultaneously: \[y_1 \sim \text{Poisson}(\exp(\mathbf{z}_1\boldsymbol{\delta}_1 + \alpha_1 y_2 + \rho_1 \hat{v}_2))\] 3. Inference: Standard errors must be bootstrapped (e.g., clustered by panel unit) to account for the first-stage estimation uncertainty of \(\hat{v}_2\).

This is Lin and Wooldridge (2019)’s Procedure 3. In a panel, step 1 absorbs the unit effects (reghdfe in Stata, feols in Julia) and step 2 absorbs them again (ppmlhdfe, fepois).

20.3.1.1 The first stage may absorb or average: both give the same answer

There are two ways to handle unit effects in a linear first stage, and it does not matter which we pick. Regressing \(y_{it2}\) on \(\mathbf{z}_{it}\) and unit dummies gives the fixed-effects residual \(\hat{v}_{it2}^{FE}\). Regressing \(y_{it2}\) on \(\mathbf{z}_{it}\) and the unit means \(\bar{\mathbf{z}}_i\) — the Mundlak device — gives the Mundlak residual \(\hat{v}_{it2}^{M}\). Substituting either one into the second-stage FE Poisson gives numerically identical \(\hat{\alpha}_1\) and \(\hat{\rho}_1\) (Lin and Wooldridge 2019, app. A.1–A.2).

The reason is short. Mundlak’s result is that the coefficient on \(\mathbf{z}_{it}\) in the second regression equals the within estimator \(\hat{\boldsymbol{\pi}}_2^{FE}\), so the two residuals share a slope and differ only in what is subtracted off unit by unit: \[\hat{v}_{it2}^{FE} = \hat{v}_{it2}^{M} + g_i\] for some unit-specific constant \(g_i\). Put that into the second-stage index: \[\mathbf{z}_{1,it}\boldsymbol{\delta}_1 + \alpha_1 y_{it2} + \rho_1 \hat{v}_{it2}^{FE} + c_i = \mathbf{z}_{1,it}\boldsymbol{\delta}_1 + \alpha_1 y_{it2} + \rho_1 \hat{v}_{it2}^{M} + (c_i + \rho_1 g_i)\]

The swap moves \(\rho_1 g_i\) into the unit effect, and the unit effect is a free parameter that FE Poisson absorbs without restriction. The model is reparameterized, not changed. Nothing reaches \(\hat{\alpha}_1\) or \(\hat{\rho}_1\).

This holds only when the first stage averages or absorbs on the same dimension the second stage absorbs. It is also specific to the linear first stage: for a binary \(y_2\) the first stage is nonlinear, the residual is not shifted by a constant, and the choice between dummies and Mundlak means becomes a real one (Section 20.3.4).


20.3.2 Binary \(y_2\): why the linear reduced form fails

When \(y_2 \in \{0, 1\}\) is binary, the linear reduced-form residual \(v_2 = y_2 - \mathbf{z}\boldsymbol{\pi}_2\) takes exactly two values conditional on \(\mathbf{z}\): \[v_2 \mid \mathbf{z} = \begin{cases} 1 - \mathbf{z}\boldsymbol{\pi}_2 & \text{with probability } p(\mathbf{z}) \\ -\mathbf{z}\boldsymbol{\pi}_2 & \text{with probability } 1 - p(\mathbf{z}) \end{cases} \tag{20.5}\]

The support \(\{-\mathbf{z}\boldsymbol{\pi}_2, 1 - \mathbf{z}\boldsymbol{\pi}_2\}\), the probabilities, and the conditional variance \(\mathrm{Var}(v_2 \mid \mathbf{z}) = p(\mathbf{z})[1 - p(\mathbf{z})]\) are all direct functions of \(\mathbf{z}\).

As Wooldridge (2010, 746) emphasizes:

“The assumption that \(e_1\) in (18.39) is independent of \(v_2\) and \(\mathbf{z}\) rules out most cases where \(y_2\) has some discreteness, such as with binary, count, or corner responses. (In particular, the independence assumption likewise fails unless \(v_2\) is independent of \(\mathbf{z}\), and it would be very unusual for a discrete variable to be expressible as a linear equation with additive error independent of \(\mathbf{z}\).)”

A distribution whose support moves with \(\mathbf{z}\) cannot be independent of \(\mathbf{z}\) (unless \(\boldsymbol{\pi}_2 = \mathbf{0}\), meaning there is no first stage). Therefore, \(v_2 \perp \mathbf{z}\) fails mathematically for any discrete endogenous variable.

20.3.2.1 Where the independence assumption belongs

The issue is not that the observed residual is discrete. The generalized residual of Section 20.3.4 is also two-valued given \(\mathbf{z}\).

The critical distinction is which object independence is asserted about:

  • The linear CF asserts independence of the observed discrete residual \(v_2\), which is impossible.
  • Terza’s threshold model asserts independence of the continuous latent probit error \(v_2 \mid \mathbf{z} \sim N(0, 1)\), which is the standard assumption of probit models.

20.3.2.2 What survives: the exogeneity test

The linear-residual construction remains fully valid as a Hausman-type exogeneity test (Wooldridge 2010, 744). Under the null hypothesis of exogeneity (\(H_0: \rho_1 = 0\)), \(c_1\) does not enter the model, so none of the joint independence assumptions are needed. A standard \(t\)-test on \(\hat{v}_2 = 0\) in the Poisson second stage provides an asymptotically valid test for endogeneity.


20.3.3 Terza’s (1998) exact correction

To resolve the discreteness problem, Terza (1998) and Wooldridge (2010) (sec. 18.5) replace the linear probability model with a latent threshold model: \[y_2 = \mathbf{1}[\mathbf{z}\boldsymbol{\pi}_2 + v_2 \ge 0], \qquad v_2 \mid \mathbf{z} \sim N(0, 1) \tag{20.6}\]

Let \((c_1, v_2)\) be jointly normal and independent of \(\mathbf{z}\), with \(c_1 = \rho_1 v_2 + e_1\), where \(e_1\) is normal and independent of \((\mathbf{z}, v_2)\). Give \(e_1\) a variance \(\sigma_e^2\) that does not depend on \(\rho_1\), and a mean of \(-\sigma_e^2/2\), so that \(E[\exp(e_1)] = 1\), the normalization of the previous section. (Any other constant in \(E[\exp(e_1)]\) only shifts the intercept.)

Conditioning on the latent error \(v_2\) yields: \[E(y_1 \mid \mathbf{z}, v_2) = \exp\bigl(\mathbf{z}_1\boldsymbol{\delta}_1 + \alpha_1 y_2\bigr)\exp(\rho_1 v_2)\]

Averaging over the truncated normal distribution of \(v_2\) conditional on the observed binary outcome \(y_2 \in \{0, 1\}\) gives the exact conditional mean: \[E(y_1 \mid \mathbf{z}, y_2) = \exp(\mathbf{z}_1\boldsymbol{\delta}_1 + \alpha_1 y_2) \cdot h(y_2, \mathbf{z}\boldsymbol{\pi}_2, \rho_1) \tag{20.7}\]

where: \[h(y_2, \mathbf{z}\boldsymbol{\pi}_2, \rho_1) = \exp(\rho_1^2 / 2) \left[ y_2 \frac{\Phi(\rho_1 + \mathbf{z}\boldsymbol{\pi}_2)}{\Phi(\mathbf{z}\boldsymbol{\pi}_2)} + (1 - y_2) \frac{1 - \Phi(\rho_1 + \mathbf{z}\boldsymbol{\pi}_2)}{1 - \Phi(\mathbf{z}\boldsymbol{\pi}_2)} \right] \tag{20.8}\]

Here \(\Phi(\cdot)\) denotes the standard normal CDF, \(\rho_1 = \mathrm{Cov}(c_1, v_2)\) is a projection coefficient on the scale of the probit index, and \(\exp(\rho_1^2 / 2)\) is the lognormal correction factor.

20.3.3.1 Estimation by a one-dimensional profile likelihood with an offset

Notice that for any fixed value of \(\rho_1\), \(\log h(y_2, \mathbf{z}\hat{\boldsymbol{\pi}}_2, \rho_1)\) is a known data column. The conditional mean can be written as: \[E(y_1 \mid \mathbf{z}, y_2, \alpha_i) = \exp\bigl(\mathbf{z}_1\boldsymbol{\delta}_1 + \alpha_1 y_2 + \alpha_i + \log h(\rho_1)\bigr) \tag{20.9}\]

This is a standard Poisson regression with an offset.

Because \(h(\cdot)\) enters multiplicatively, individual fixed effects factor out in closed form: \[\exp(\hat{\alpha}_i) = \frac{\sum_t y_{1,it}}{\sum_t \exp(\mathbf{z}_{1,it}\boldsymbol{\delta}_1 + \alpha_1 y_{2,it}) h_{it}(\rho_1)}\]

Fixed effects are absorbed without an incidental parameters problem. The full model is estimated by profiling out \((\boldsymbol{\delta}_1, \alpha_1)\) and optimizing over the single scalar \(\rho_1 \in [-2, 2]\) using 1D optimization.

20.3.3.2 Terza’s estimators and FIML

Terza (1998) proposes three estimators:

  1. Full-Information Maximum Likelihood (FIML): Evaluates the joint likelihood of \(y_1\) and \(y_2\) by integrating out \(v_2\) via Gauss–Hermite quadrature.
  2. Two-Stage Method of Moments / QMLE: The two-step estimator above (probit followed by QMLE on Equation 20.7).
  3. Nonlinear Weighted Least Squares: For the fully parametric specification.

In panel data, FIML has two major drawbacks:

  • It requires the full Poisson density inside the quadrature integral, losing QMLE robustness to overdispersion.
  • It cannot absorb fixed effects; entering unit dummies destroys likelihood separability, leading to severe incidental parameters bias and convergence failures.

By contrast, the two-step profile QMLE concentrates out fixed effects cleanly.


20.3.4 The generalized-residual CF and the Mundlak device

What enters the Poisson index is \(\log h\), so we expand \(\log h\) itself around \(\rho_1 = 0\). Write \(\eta = \mathbf{z}\boldsymbol{\pi}_2\) for the probit index and \(\lambda(u) = \phi(u)/\Phi(u)\) for the inverse Mills ratio. For a treated observation, \[\log h(1, \eta, \rho_1) = \frac{\rho_1^2}{2} + \log \Phi(\eta + \rho_1) - \log \Phi(\eta). \tag{20.10}\]

At \(\rho_1 = 0\) it is zero, its first derivative is \(\lambda(\eta)\), and its second derivative is \(1 + \lambda'(\eta + \rho_1)\). For an untreated observation the same steps give the first derivative \(-\phi(\eta)/(1 - \Phi(\eta))\). So to first order \[\log h(y_2, \mathbf{z}\boldsymbol{\pi}_2, \rho_1) \approx \rho_1 \hat{r}_2, \tag{20.11}\]

where \(\hat{r}_2\) is the generalized residual (Gourieroux et al. 1987): \[\hat{r}_2 = y_2 \frac{\phi(\mathbf{z}\hat{\boldsymbol{\pi}}_2)}{\Phi(\mathbf{z}\hat{\boldsymbol{\pi}}_2)} - (1 - y_2)\frac{\phi(\mathbf{z}\hat{\boldsymbol{\pi}}_2)}{1 - \Phi(\mathbf{z}\hat{\boldsymbol{\pi}}_2)}\]

and the conditional mean becomes \[E(y_1 \mid \mathbf{z}, y_2) \approx \exp(\mathbf{z}_1\boldsymbol{\delta}_1 + \alpha_1 y_2 + \rho_1 \hat{r}_2).\]

The remainder has a bound that holds everywhere. The derivative of the inverse Mills ratio is \(\lambda'(u) = -\lambda(u)[u + \lambda(u)]\), which lies in \((-1, 0)\) for every \(u\). The second derivative of \(\log h\) therefore lies in \((0, 1)\), and the untreated case gives the same range. By Taylor’s theorem, at the true \(\boldsymbol{\pi}_2\), \[0 < \log h(y_2, \eta, \rho_1) - \rho_1 r_2 < \frac{\rho_1^2}{2} \tag{20.12}\]

for every index \(\eta\) and every \(\rho_1\). On the scale of the mean, the generalized-residual CF misses Terza’s correction by a factor between \(1\) and \(\exp(\rho_1^2/2)\), uniformly over the support of the index. It is a first-order approximation whose error depends on \(|\rho_1|\) and not on how far the index reaches into a tail.

20.3.4.1 Probit and logit generalized residuals

For a logit first stage (\(\Lambda(\eta) = \frac{1}{1 + e^{-\eta}}\)), the generalized residual collapses algebraically: \[\hat{r}_2 = y_2 \frac{\Lambda'(\eta)}{\Lambda(\eta)} - (1 - y_2)\frac{\Lambda'(\eta)}{1 - \Lambda(\eta)} = y_2 (1 - \hat{p}_2) - (1 - y_2)\hat{p}_2 = y_2 - \hat{p}_2 \tag{20.13}\]

The logit generalized residual is simply the raw response residual (\(y_2 - \hat{p}_2\)).

20.3.4.2 Panel fixed effects: the Mundlak device

In short panels (\(T\) small, \(N \to \infty\)), estimating individual unit dummies in a nonlinear first stage (probit or logit) suffers from the incidental parameters problem, producing heavily biased first-stage estimates and distorted generalized residuals.

As Lin and Wooldridge (2019) show, the standard solution is the Mundlak device (Correlated Random Effects):

  1. Add the unit-specific time averages of all time-varying exogenous covariates and instruments: \[\mathbf{w}_{it} = (1, \mathbf{z}_{it}, \bar{\mathbf{z}}_i)\]
  2. Estimate a pooled probit or logit model on \(\mathbf{w}_{it}\) and compute the generalized residuals \(\hat{r}_{2,it}\).
  3. Include \(\hat{r}_{2,it}\) in a fixed-effects Poisson second stage. The unit dummies are absorbed there, and FE Poisson is consistent with \(T\) fixed, so the incidental parameters problem does not reappear.

20.3.5 Multiplicative-moment GMM

Instead of a control function, Mullahy (1997) proposes multiplicative moment conditions: \[E\left[ \mathbf{z}' \left( y_1 \exp(-\mathbf{z}_1\boldsymbol{\delta}_1 - \alpha_1 y_2) - 1 \right) \right] = \mathbf{0} \tag{20.14}\]

Under \(E[\exp(c_1) \mid \mathbf{z}] = 1\), this condition holds without requiring the first-stage model for \(y_2\) to be correctly specified.

20.3.5.1 Panel fixed effects by quasi-differencing

In panel data with unobserved individual heterogeneity \(\eta_i\), write \(y_{it} = \eta_i \exp(\mathbf{x}_{it}\boldsymbol{\beta})\, u_{it}\), where \(\mathbf{x}_{it}\) may contain the endogenous \(y_{2,it}\) and the instruments \(\mathbf{z}_i = (\mathbf{z}_{i1}, \ldots, \mathbf{z}_{iT})\) are strictly exogenous, \(E[u_{it} \mid \mathbf{z}_i, \eta_i] = 1\) in every period. Individual effects cannot be removed by additive demeaning; they must be eliminated multiplicatively. With endogenous regressors the transformation matters. Wooldridge’s quasi-difference, \(y_{it}\exp(\mathbf{x}_{is}\boldsymbol{\beta})/\exp(\mathbf{x}_{it}\boldsymbol{\beta}) - y_{is} = \eta_i \exp(\mathbf{x}_{is}\boldsymbol{\beta})(u_{it} - u_{is})\), is valid for strictly exogenous regressors (Wooldridge 1999), but when \(\mathbf{x}_{is}\) is correlated with \(u_{is}\) its mean is not zero. Windmeijer (2000) instead divides each period’s outcome by its own index before differencing: \[E\left[ \mathbf{z}_{it}' \left( \frac{y_{it}}{\exp(\mathbf{x}_{it}\boldsymbol{\beta})} - \frac{y_{is}}{\exp(\mathbf{x}_{is}\boldsymbol{\beta})} \right) \right] = \mathbf{0}. \tag{20.15}\]

Both ratios have conditional mean \(\eta_i\) given \((\mathbf{z}_i, \eta_i)\), so their difference has mean zero given \(\mathbf{z}_i\). This requires repeated time periods and strict exogeneity of the instruments across periods. With instruments that are only predetermined, Chamberlain (1992) gives a sequential version for \(s = t - 1\).


20.4 Why recommend generalized residuals over exact Terza

Given that Terza’s correction (Terza 1998) is theoretically exact under bivariate normality, why do applied econometricians and textbooks (Wooldridge 2010, 2014; Lin and Wooldridge 2019) frequently recommend the Generalized-Residual Control Function?

There are five key reasons:

20.4.1 A built-in Hausman exogeneity test in one step

In the generalized residual model: \[\log E(y_1 \mid \mathbf{z}, y_2) = \mathbf{z}_1\boldsymbol{\delta}_1 + \alpha_1 y_2 + \rho_1 \hat{r}_2\]

The coefficient on \(\hat{r}_2\) estimates \(\rho_1\), and its \(t\)-statistic is a direct, asymptotically valid variable-addition test for exogeneity (\(H_0: \rho_1 = 0\)).

  • Under \(H_0\), none of the joint normality or reduced-form assumptions are required (Wooldridge 2010, 744).
  • Terza’s exact method does not yield a simple linear \(t\)-statistic directly beside \(\hat{\alpha}_1\).

20.4.2 Standard software

  • Generalized Residual: Fits directly in standard software without custom numerical optimization.
  • Terza’s Exact 2-Step: Requires writing a custom 1D profile likelihood wrapper to search over \(\rho_1\) with an offset.

20.4.4 Robustness to non-normality

  • Terza’s correction is exact only under strict joint bivariate normality.
  • If the true unobservables \((c_1, v_2)\) are non-normal (e.g. skewed or heavy-tailed), \(h(\cdot)\) has the wrong functional form. The profile then picks the \(\rho_1\) that best fits a curve the data do not follow, and that misspecification passes straight into \(\hat{\alpha}_1\). This is misspecification bias, not overfitting — there is only one extra parameter, so there is nothing to overfit with.
  • The generalized residual commits to less. It controls for \(E[v_2 \mid y_2, \mathbf{z}]\) and stops at first order, so a wrong \(h\) cannot drag it. Whether this actually wins under non-normality is an open question; Lin and Wooldridge (2019) leave “investigations into the quality of CF approximations in discrete cases to future research.”

20.4.5 The approximation error shrinks with the endogeneity

The error is at most \(\rho_1^2/2\) on the log scale (Equation 20.12), so it vanishes quadratically as \(\rho_1 \to 0\), and the second stage reports a coefficient on \(\hat{r}_2\) that estimates \(\rho_1\) to that same first order. The bound does not depend on where the probit index sits. Terza’s factor \(h\) itself is asymmetric and treatment-state specific: for a treated observation it scales the mean by \(\exp(\rho_1^2/2)\,\Phi(\eta + \rho_1)/\Phi(\eta)\), which grows without bound in the lower tail of the index when \(\rho_1 > 0\), and the untreated factor grows in the upper tail when \(\rho_1 < 0\). But the control function grows with it. In the lower tail \(\hat{r}_2 = \lambda(\eta) \approx -\eta\) for a treated unit, so \(\exp(\rho_1 \hat{r}_2)\) rises at the same exponential rate as \(h\), and their ratio stays between \(1\) and \(\exp(\rho_1^2/2)\). Within that band the error does vary with the index, from near zero in the lower tail to near \(\rho_1^2/2\) in the upper tail for treated units, so it is not absorbed entirely by the intercept. What governs it is \(|\rho_1|\).

20.4.6 Practical strategy

Situation Recommended Estimator Rationale
Routine empirical analysis & testing Generalized-Residual CF Fast, standard 1-line command, built-in \(t\)-test for \(\rho_1 = 0\), works with Logit (\(y_2 - \hat{p}_2\)), handles panel FE via Mundlak.
\(|\hat{\rho}_1|\) small Generalized-Residual CF alone The \(O(\rho_1^2)\) error is smallest exactly here.
\(|\hat{\rho}_1|\) large, either sign Add the Terza Exact Profiled 2-Step The log-scale remainder is at most \(\rho_1^2/2\) wherever the index sits, so it matters only when \(|\rho_1|\) is large, and it can for either sign. Fit the exact model alongside and report both; if they agree the approximation was safe, and if they do not, the exact one is right provided the probit is.

20.5 The four estimators compared

Estimator First Stage Second Stage Adjustment Consistency (Binary \(y_2\)) Panel Fixed Effects Standard Errors
Linear CF Linear OLS Add \(\hat{v}_2\) inside \(\exp(\cdot)\) Inconsistent Yes (Poisson with FE) Cluster Bootstrap
Generalized CF Probit / Logit (with Mundlak) Add \(\hat{r}_2\) inside \(\exp(\cdot)\) Approx. (\(O(\rho_1^2)\) error) Yes (Mundlak in 1st stage) Cluster Bootstrap
Terza Exact 2-Step Probit Profile \(\rho_1\) with offset \(\log h(\rho_1)\) Yes (under normality) Yes (Poisson with offset) Cluster Bootstrap
Multiplicative GMM Any (\(\hat{p}_2\)) Instrument \(y_2\) in moments Yes (moment-based; needs valid multiplicative moments) Needs quasi-differencing Sandwich vcov

20.6 Practical guidance: an observable diagnostic workflow

In empirical practice, we do not need to guess the confounding parameter \(\rho_1\)—the second-stage Poisson table reports a coefficient on the generalized residual \(\hat{r}_2\) that estimates it. Read that number as the control-function coefficient. It is a first-order variable-addition coefficient, and it coincides with the \(\rho_1\) inside Terza’s exact correction only to that order and only with a probit first stage. With a logit first stage the residual is on a different scale, so the two are not directly comparable without an explicit mapping.

A standard applied workflow proceeds in four steps:

  1. Estimate the Generalized-Residual CF as the baseline model:

    • For continuous \(y_2\): Add the OLS residual \(\hat{v}_2\).
    • For binary \(y_2\): Add the generalized residual \(\hat{r}_2\) (or raw response residual \(y_2 - \hat{p}_2\) if using logit).
    • In short panels (\(T\) small): Use the Mundlak device (\(\mathbf{w}_{it} = (1, \mathbf{z}_{it}, \bar{\mathbf{z}}_i)\)) in the first stage to avoid incidental parameters bias.
  2. Check the \(t\)-statistic on the residual (Exogeneity Test):
    The \(t\)-statistic on \(\hat{r}_2\) (testing \(\hat{\rho}_1 = 0\)) is an asymptotically valid Hausman-type exogeneity test. Read it as a description of how much endogeneity the data can detect. Do not read it as a licence to drop the residual — see the pretest warning below.

  3. Read the magnitude of \(\hat{\rho}_1\) (Approximation Diagnostic): judge magnitude from the coefficient and its confidence interval, not from the \(t\)-statistic.

    • If \(|\hat{\rho}_1|\) is small: the \(O(\rho_1^2)\) error is at its smallest and the Generalized-Residual CF stands on its own.
    • If \(|\hat{\rho}_1|\) is large, whatever its sign: fit Terza’s exact 2-step alongside it and report both. The gap between the two log means is at most \(\hat\rho_1^2/2\), about \(0.125\) at \(|\hat\rho_1| = 0.5\), a 13% scale difference, which is a guide to when the comparison matters. Do not read a threshold off \(\hat{\rho}_1\) alone — the comparison of the two fits is the diagnostic, not a rule of thumb.
  4. Inference: the second-stage standard errors ignore first-stage estimation error, so they need a correction whenever \(\rho_1 \neq 0\). In a panel, resampling whole units is the natural implementation, provided there are enough units for the bootstrap to behave; with few clusters it needs a small-cluster correction of its own. In a cross-section, resample observations or use an analytic two-step correction. Under \(H_0: \rho_1 = 0\) the uncorrected \(t\)-statistic on \(\hat{r}_2\) is already valid, which is why the exogeneity test in step 2 needs no bootstrap.

20.6.1 Do not use the exogeneity test to choose the model

The tempting next move is to let step 2 pick the specification: if the \(t\)-statistic on \(\hat{r}_2\) is insignificant, drop the residual and report the plain FE Poisson; if it is significant, keep the control function. This is a pretest estimator. The objection is not that its point estimates are uniformly worse than those of either model it chooses between. It is that the inference reported afterwards is no longer valid at its nominal level.

Guggenberger (2010a) works this out for the linear case. A Hausman pretest followed by OLS-or-2SLS, with the second-stage \(t\)-test reported at its nominal level, has asymptotic size equal to one: there are points in the parameter space where the procedure rejects a true null with probability approaching 1. The mechanism is a sequence of local alternatives. Let the endogeneity drift toward zero at rate \(n^{-1/2}\). The pretest then has low power and often fails to reject, so the procedure falls back on the estimator that ignores endogeneity — but at that drift rate the bias of that estimator is the same order as its standard error, so the reported confidence interval is centred in the wrong place by about its own width. Taking the supremum of rejection probability over the parameter space picks out exactly these points. Guggenberger (2010b) obtains the same conclusion for the panel Hausman test between fixed and random effects.

These results are proved for linear models, and we are not aware of an analogous theorem for the Poisson control function. The mechanism does not depend on linearity: it needs only a pretest with low power against local endogeneity and a fallback estimator whose bias does not vanish faster than its standard error, and both are present here. We treat it as a warning that carries over rather than a result that has been established in this setting.

The practical rule is to report the naive FE Poisson and the control-function FE Poisson side by side and let the reader see both. The \(t\)-statistic on \(\hat{r}_2\) still belongs in the table as a test of \(\rho_1 = 0\). For the magnitude that step 3 needs, read \(\hat{\rho}_1\) itself and its confidence interval. A \(t\)-statistic combines the coefficient with its precision and measures neither on its own. What it must not do is silently delete one of the two columns.


20.7 Implementation in Julia and Stata

Below are concise, copy-pasteable implementation templates in Julia (Panelest.jl) and Stata (ppmlhdfe).

20.7.1 Julia (Panelest.jl)

The simulation follows the correlated-random-effects setup the estimator assumes. There are 500 units observed over 5 periods, an excluded instrument \(z_{it}\) and an exogenous covariate \(x_{it}\), both standard normal. The unit effect in the treatment equation is \(c_i = 0.6\bar z_i + 0.6\bar x_i\), a function of the unit means, which is the Mundlak assumption in its simplest form. Treatment is \(y_{2,it} = 1[0.8 z_{it} + 0.5 x_{it} + c_i + v_{it} \geq 0]\) with \(v_{it} \sim N(0, 1)\), so the probit on \((z_{it}, x_{it}, \bar z_i, \bar x_i)\) is correctly specified. The outcome is Poisson with mean \(\exp(0.5 + 0.8 y_{2,it} + 0.4 x_{it} + a_i + 0.2 v_{it})\), where the unit effect \(a_i = c_i + N(0, 1)\) is absorbed by the fixed effects and \(0.2 v_{it}\) is the endogeneity. The true \(\alpha_1\) is 0.8 and the true \(\rho_1\) is 0.2.

Code
# 1. Simulate a panel (500 units, 5 periods) from the CRE model
Random.seed!(123)
n_i, n_t = 500, 5; n = n_i * n_t
id   = repeat(1:n_i, inner = n_t)
time = repeat(1:n_t, outer = n_i)
z    = randn(n)                                    # excluded instrument
x    = randn(n)                                    # exogenous covariate
zbar = [mean(z[id .== i]) for i in 1:n_i][id]
xbar = [mean(x[id .== i]) for i in 1:n_i][id]
c_i  = 0.6 .* zbar .+ 0.6 .* xbar                  # unit effect through the unit means
v2   = randn(n)                                    # first-stage error, N(0, 1)
a_i  = c_i .+ randn(n_i)[id]                       # outcome unit effect (absorbed by FE)
y2     = Int.(0.8 .* z .+ 0.5 .* x .+ c_i .+ v2 .>= 0)
lambda = exp.(0.5 .+ 0.8 .* y2 .+ 0.4 .* x .+ a_i .+ 0.2 .* v2)
y1     = rand.(Poisson.(lambda))
df     = DataFrame(y1 = y1, y2 = y2, z = z, x = x, id = id, time = time)
transform!(groupby(df, :id), :z => mean => :mean_z, :x => mean => :mean_x)
df.tcat = string.(df.time)
function cf_fit(d)
    fs  = feprobit(d, @formula(y2 ~ z + x + mean_z + mean_x + tcat))   # period dummies as regressors
    eta = fs.eta
    nd  = Normal()
    d = copy(d)
    d.r2 = @. ifelse(d.y2 == 1, pdf(nd, eta) / cdf(nd, eta), -pdf(nd, eta) / (1 - cdf(nd, eta)))
    fepois(d, @formula(y1 ~ y2 + r2 + x + fe(id) + fe(time)))
end
b(m, v) = coef(m)[findfirst(==(v), coefnames(m))]
s(m, v) = stderror(m)[findfirst(==(v), coefnames(m))]
m_naive = fepois(df, @formula(y1 ~ y2 + x + fe(id) + fe(time)))
m_cf    = cf_fit(df)
show_regression_html(m_naive; title = "Naive FE Poisson")
show_regression_html(m_cf; title = "Generalized residual CF")

# 5. Cluster bootstrap over units: r2 is a generated regressor, so the
#    second-stage standard errors above are not valid when rho1 != 0.
#    Resampled units are copied whole (their means do not change); each copy
#    gets its own id, so its own fixed effect.
rows = [findall(==(i), df.id) for i in 1:n_i]
B = 499; boot = zeros(B, 2)
Threads.@threads for bb in 1:B
    draw = rand(Xoshiro(1000 + bb), 1:n_i, n_i)
    d = df[reduce(vcat, rows[draw]), :]
    d.id = reduce(vcat, [fill(k, length(rows[draw[k]])) for k in 1:n_i])
    m = cf_fit(d)
    boot[bb, :] = [b(m, "y2"), b(m, "r2")]
end
@printf "true alpha1 = %.2f, true rho1 = %.2f\n" 0.8 0.2
@printf "naive          alpha1 = %.4f\n" b(m_naive, "y2")
@printf "generalized CF alpha1 = %.4f (naive SE %.4f, bootstrap SE %.4f)\n" b(m_cf, "y2") s(m_cf, "y2") std(boot[:, 1])
@printf "               rho1   = %.4f (naive SE %.4f, bootstrap SE %.4f)\n" b(m_cf, "r2") s(m_cf, "r2") std(boot[:, 2])

Naive FE Poisson

Estimate Std. Error t value Pr(>|t|)
y2 1.105 0.026 42.704 < 2e-16 ***
x 0.346 0.010 33.592 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Generalized residual CF

Estimate Std. Error t value Pr(>|t|)
y2 0.835 0.050 16.695 < 2e-16 ***
r2 0.203 0.032 6.300 2.979e-10 ***
x 0.382 0.012 32.304 < 2e-16 ***
---
Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
true alpha1 = 0.80, true rho1 = 0.20
naive          alpha1 = 1.1052
generalized CF alpha1 = 0.8346 (naive SE 0.0500, bootstrap SE 0.0608)
               rho1   = 0.2031 (naive SE 0.0322, bootstrap SE 0.0415)

The naive fixed-effects Poisson gives 1.105, well above the true 0.8: the endogeneity \(0.2 v_{it}\) raises the outcomes of the units that select into treatment. The generalized-residual CF gives 0.835, with a cluster-bootstrap standard error of 0.061, and estimates \(\rho_1\) at 0.203 (0.042). Both are within one standard error of the truth, and the approximation error of Equation 20.12 is at most \(0.2^2/2 = 0.02\) here. The bootstrap standard errors are 22% and 29% larger than the naive ones: the generated regressor adds uncertainty that the second-stage standard errors leave out. (The R companion runs the same design with a different random draw.)

20.7.2 Stata (ppmlhdfe)

* ==============================================================================
* Generalized-Residual Control Function in Stata using ppmlhdfe
* ==============================================================================

* 1. Mundlak Device: Calculate unit-level means of time-varying variables
bysort id: egen mean_z = mean(z)
bysort id: egen mean_x = mean(x)

* 2. Step 1: Probit First Stage on pooled data with Mundlak means
probit y2 z x mean_z mean_x i.time
predict double eta, xb
gen double r2 = cond(y2 == 1, normalden(eta)/normal(eta), -normalden(eta)/(1 - normal(eta)))

* (Alternatively, for a Logit first stage: raw response residual)
* logit y2 z x mean_z mean_x i.time
* predict double phat, pr
* gen double r2 = y2 - phat

* 3. Step 2: Fixed-Effects Poisson Second Stage
ppmlhdfe y1 y2 r2 x, absorb(id time)

* 4. Inference: Panel Cluster Bootstrap Program
capture program drop boot_poisson_cf
program define boot_poisson_cf, rclass
    * A resampled unit is copied whole, so its Mundlak means equal the
    * original ones; recomputing them by new_id is harmless but not needed.
    * What new_id is needed for is the fixed effect: a unit drawn twice must
    * get two fixed effects. The probit and the Poisson both refit on each draw,
    * which is what carries first-stage uncertainty into the second stage.
    quietly bysort new_id: egen double mz_b = mean(z)
    quietly bysort new_id: egen double mx_b = mean(x)

    * First stage
    quietly probit y2 z x mz_b mx_b i.time
    quietly predict double eta_b, xb
    quietly gen double r2_b = cond(y2 == 1, normalden(eta_b)/normal(eta_b), -normalden(eta_b)/(1 - normal(eta_b)))

    * Second stage
    quietly ppmlhdfe y1 y2 r2_b x, absorb(new_id time)
    return scalar alpha1 = _b[y2]
    return scalar rho1   = _b[r2_b]

    drop eta_b r2_b mz_b mx_b
end

bootstrap r(alpha1) r(rho1), reps(500) cluster(id) idcluster(new_id): boot_poisson_cf

20.8 Summary

In an exponential model the unobserved confounder enters multiplicatively, so the linear 2SLS logic does not carry over. A control function still works. The first-stage residual goes inside the exponential, and fixed-effects Poisson absorbs unit effects without an incidental-parameters problem. The price is a stronger assumption: the confounder’s exponential moment must be constant given the instruments and the first-stage residual, which is more than zero correlation.

For a continuous endogenous regressor, the OLS residual is the control function. For a binary one, Terza’s correction is exact under joint normality. The generalized residual is its first-order approximation, and for a logit first stage it is just the response residual. In short panels the Mundlak device handles the first stage. Multiplicative-moment GMM is an alternative that needs no first-stage model. Standard errors need a cluster bootstrap. We report the naive and the control-function estimates side by side, because choosing between them by an exogeneity pretest distorts inference.