Augments a data frame with the unit-level means of the time-varying numeric
covariates in formula (both equations of a two-part y ~ x | z formula),
and returns the augmented formula and data. Fitting any estimator in the
package on the result implements the Mundlak / correlated-random-effects
specification: the coefficients on the original covariates recover the
within-unit effects, while the coefficients on the unit means capture (and
test) the correlation between the covariates and the unit effect. For
ordered and inflated ordered models this is the recommended panel device:
it avoids the incidental-parameters bias of unit dummies in short panels
while preserving between-unit variation, and it pairs naturally with
cluster-robust standard errors (cluster = unit) or a random intercept
(re = unit).
Value
A list with formula (the augmented formula, keeping the |
structure), data (the augmented data frame), and added (the names of
the unit-mean columns).
References
Mundlak, Y. (1978). On the pooling of time series and cross section data. Econometrica, 46, 69-85. Wooldridge, J.M. (2010). Econometric Analysis of Cross Section and Panel Data, 2nd ed.
Examples
set.seed(1)
d <- riop(600, beta = c(0.8, -0.5), tau = c(-0.5, 0.7), gamma = c(0.4, 1), inflate = "bottom")
d$unit <- rep(1:30, each = 20)
m <- mundlak(y ~ x1 + x2 | z1, d, unit = "unit")
m$formula
#> y ~ x1 + x2 + x1_mean + x2_mean | z1 + z1_mean
#> <environment: 0x563c5e74c970>
fit <- iop(m$formula, m$data, inflate = "bottom", cluster = "unit")
coef(fit)[m$added] # unit-mean coefficients
#> x1_mean x2_mean <NA>
#> 0.1176759 -0.4115000 NA