Compute average partial effects after fitting binary choice models with a 1,2,3-way error component
Source:R/apes.R
apes.Rd
apes
is a post-estimation routine that can be used
to estimate average partial effects with respect to all covariates in the
model and the corresponding covariance matrix. The estimation of the
covariance is based on a linear approximation (delta method) plus an
optional finite population correction. Note that the command automatically
determines which of the regressors are binary or non-binary.
Remark: The routine currently does not allow to compute average partial effects based on functional forms like interactions and polynomials.
Arguments
- object
an object of class
"bias_corr"
or"feglm"
; currently restricted tobinomial
.- n_pop
unsigned integer indicating a finite population correction for the estimation of the covariance matrix of the average partial effects proposed by Cruz-Gonzalez, Fernández-Val, and Weidner (2017). The correction factor is computed as follows: \((n^{\ast} - n) / (n^{\ast} - 1)\), where \(n^{\ast}\) and \(n\) are the sizes of the entire population and the full sample size. Default is
NULL
, which refers to a factor of zero and a covariance obtained by the delta method.- panel_structure
a string equal to
"classic"
or"network"
which determines the structure of the panel used."classic"
denotes panel structures where for example the same cross-sectional units are observed several times (this includes pseudo panels)."network"
denotes panel structures where for example bilateral trade flows are observed for several time periods. Default is"classic"
.- sampling_fe
a string equal to
"independence"
or"unrestricted"
which imposes sampling assumptions about the unobserved effects."independence"
imposes that all unobserved effects are independent sequences."unrestricted"
does not impose any sampling assumptions. Note that this option only affects the optional finite population correction. Default is"independence"
.- weak_exo
logical indicating if some of the regressors are assumed to be weakly exogenous (e.g. predetermined). If object is of class
"bias_corr"
, the option will be automatically set toTRUE
if the chosen bandwidth parameter is larger than zero. Note that this option only affects the estimation of the covariance matrix. Default isFALSE
, which assumes that all regressors are strictly exogenous.
References
Cruz-Gonzalez, M., I. Fernández-Val, and M. Weidner (2017). "Bias corrections for probit and logit models with two-way fixed effects". The Stata Journal, 17(3), 517-545.
Czarnowske, D. and A. Stammann (2020). "Fixed Effects Binary Choice Models: Estimation and Inference with Long Panels". ArXiv e-prints.
Fernández-Val, I. and M. Weidner (2016). "Individual and time effects in nonlinear panel models with large N, T". Journal of Econometrics, 192(1), 291-312.
Fernández-Val, I. and M. Weidner (2018). "Fixed effects estimation of large-t panel data models". Annual Review of Economics, 10, 109-138.
Hinz, J., A. Stammann, and J. Wanner (2020). "State Dependence and Unobserved Heterogeneity in the Extensive Margin of Trade". ArXiv e-prints.
Neyman, J. and E. L. Scott (1948). "Consistent estimates based on partially consistent observations". Econometrica, 16(1), 1-32.
Examples
# subset trade flows to avoid fitting time warnings during check
set.seed(123)
trade_2006 <- trade_panel[trade_panel$year == 2006, ]
trade_2006 <- trade_2006[sample(nrow(trade_2006), 500), ]
trade_2006$trade <- ifelse(trade_2006$trade > 100, 1L, 0L)
# Fit 'feglm()'
mod <- feglm(trade ~ lang | year, trade_2006, family = binomial())
# Compute average partial effects
mod_ape <- apes(mod)
summary(mod_ape)
#> Estimates:
#> Estimate Std. Error z value Pr(>|z|)
#> lang -0.008055 0.065345 -0.123 0.902
# Apply analytical bias correction
mod_bc <- bias_corr(mod)
summary(mod_bc)
#> Formula: trade ~ lang | year
#> <environment: 0x5680898b2c28>
#>
#> Family: Binomial
#>
#> Estimates:
#>
#> | | Estimate | Std. Error | z value | Pr(>|z|) |
#> |------|----------|------------|---------|----------|
#> | lang | -0.0341 | 0.2774 | -0.1230 | 0.9021 |
#>
#> Significance codes: *** 99.9%; ** 99%; * 95%; . 90%
#>
#> Number of observations: Full 500; Missing 0; Perfect classification 0
#>
#> Number of Fisher Scoring iterations: 3
# Compute bias-corrected average partial effects
mod_ape_bc <- apes(mod_bc)
summary(mod_ape_bc)
#> Estimates:
#> Estimate Std. Error z value Pr(>|z|)
#> lang -0.008086 0.065345 -0.124 0.902