| Type: | Package |
| Title: | Binary Choice Models with Fixed Effects |
| Version: | 0.7.3 |
| Description: | Estimates fixed effects binary choice models (logit and probit) with potentially many individual fixed effects and computes average partial effects. Incidental parameter bias can be reduced with an asymptotic bias correction proposed by Fernandez-Val (2009) <doi:10.1016/j.jeconom.2009.02.007>. |
| License: | GPL-2 |GPL-3 [expanded from: GPL (≥ 2)] |
| Depends: | R (≥ 3.1.0) |
| Imports: | data.table, Formula, Rcpp, stats |
| LinkingTo: | Rcpp, RcppArmadillo |
| URL: | https://github.com/amrei-stammann/bife |
| BugReports: | https://github.com/amrei-stammann/bife/issues |
| RoxygenNote: | 7.3.3 |
| LazyData: | true |
| Suggests: | alpaca, knitr, rmarkdown |
| VignetteBuilder: | knitr |
| Encoding: | UTF-8 |
| NeedsCompilation: | yes |
| Packaged: | 2025-10-26 13:55:12 UTC; daniel |
| Author: | Amrei Stammann |
| Maintainer: | Amrei Stammann <amrei.stammann@uni-bayreuth.de> |
| Repository: | CRAN |
| Date/Publication: | 2025-10-27 08:30:02 UTC |
Asymptotic bias correction for binary choice Models with fixed effects
Description
bias_corr is a post-estimation routine that can be used to substantially reduce the incidental parameter bias problem (Neyman and Scott (1948)) present in non-linear fixed effects models (see Fernández-Val and Weidner (2018) for an overview). The command applies the analytical bias correction derived by Fernández-Val (2009) to obtain bias-corrected estimates of the structural parameters.
Remark: Fernández-Val (2009) further refined the bias correction of Hahn and Newey (2004). The correction is now also applicable to models with weakly exogenous regressors.
Usage
bias_corr(object, L = 0L)Arguments
object | an object of class |
L | unsigned integer indicating a bandwidth for the estimation of spectral densities proposed by Hahn and Kuersteiner (2011). Default is zero, which should be used if all regressors are assumed to be strictly exogenous. In the presence of weakly exogenous or predetermined regressors, Fernández-Val and Weidner (2018) suggest to choose a bandwidth not higher than four. |
Value
The functionbias_corr returns a named list of class"bife".
References
Fernández-Val, I. (2009). "Fixed effects estimation of structural parameters and marginal effects in panel probit models". Journal of Econometrics 150(1), 71-85.
Fernández-Val, I. and M. Weidner (2018). "Fixed effects estimation of large-t panel data models". Annual Review of Economics, 10, 109-138.
Hahn, J. and G. Kuersteiner (2011). "Bias reduction for dynamic nonlinear panel models with fixed effects". Econometric Theory, 27(6), 1152-1191.
Hahn, J. and W. Newey (2004). "Jackknife and analytical bias reduction for nonlinear panel models". Econometrica 72(4), 1295-1319.
Neyman, J. and E. L. Scott (1948). "Consistent estimates based on partially consistent observations". Econometrica, 16(1), 1-32.
Stammann, A., F. Heiss, and D. McFadden (2016). "Estimating Fixed Effects Logit Models with Large Panel Data". Working paper.
See Also
Examples
# Load 'psid' datasetlibrary(bife)dataset <- psid# Fit a static logit modelmod <- bife(LFP ~ I(AGE^2) + log(INCH) + KID1 + KID2 + KID3 + factor(TIME) | ID, dataset)summary(mod)# Apply analytical bias correctionmod_bc <- bias_corr(mod)summary(mod_bc)Efficiently fit binary choice models with fixed effects
Description
bife can be used to fit fixed effects binary choice models (logit and probit)based on an unconditional maximum likelihood approach. It is tailored for the fast estimation ofbinary choice models with potentially many individual fixed effects. The routine is based on aspecial pseudo demeaning algorithm derived by Stammann, Heiss, and McFadden (2016). Theestimates obtained are identical to the ones ofglm, but the computationtime ofbife is much lower.
Remark: The term fixed effect is used in econometrician's sense of having a full set ofindividual specific intercepts. All other parameters in the model are referred to asstructural parameters.
Usage
bife( formula, data = list(), model = c("logit", "probit"), beta_start = NULL, control = list(), bias_corr = NULL, tol_demeaning = NULL, iter_demeaning = NULL, tol_offset = NULL, iter_offset = NULL)Arguments
formula | an object of class |
data | an object of class |
model | the description of the error distribution and link function to be used in the model.For |
beta_start | an optional vector of starting values used for the structural parameters in theoptimization algorithm. Default is zero for all structural parameters. |
control | a named list of parameters for controlling the fitting process. See |
bias_corr | deprecated; see |
tol_demeaning,iter_demeaning,tol_offset,iter_offset | deprecated; see |
Details
bife drops all observations of cross-sectional units (individuals) withnon-varying response. This can de done because these observations do not contribute to theidentification of the structural parameters (perfect classification).
Ifbife does not converge this is usually a sign of linear dependence betweenone or more regressors and the fixed effects. In this case, you should carefully inspectyour model specification.
Value
The functionbife returns a named list of class"bife".
References
Stammann, A., F. Heiss, and D. McFadden (2016). "Estimating Fixed Effects Logit Models withLarge Panel Data". Working paper.
Examples
# Load 'psid' datasetlibrary(bife)dataset <- psid# Fit a static logit modelmod <- bife(LFP ~ I(AGE^2) + log(INCH) + KID1 + KID2 + KID3 + factor(TIME) | ID, dataset)summary(mod)Setbife Control Parameters
Description
Set and change parameters used for fittingbife.
Usage
bife_control( dev_tol = 1e-08, iter_max = 25L, trace = FALSE, rho_tol = NULL, conv_tol = NULL)Arguments
dev_tol | tolerance level for the first stopping condition of the maximization routine. Thestopping condition is based on the relative change of the deviance in iteration |
iter_max | unsigned integer indicating the maximum number of iterations in the maximizationroutine. Default is |
trace | logical indicating if output should be produced in each iteration. Default is |
conv_tol,rho_tol | deprecated; step-halving is now similar to |
Value
The functionbife_control returns a named list of controlparameters.
See Also
Extract estimates of structural parameters or fixed effects
Description
coef.bife is a generic function which extracts estimates of the structural parameters or fixed effects from objects returned bybife.
Usage
## S3 method for class 'bife'coef(object, type = c("sp", "fe"), corrected = NULL, fixed = NULL, ...)Arguments
object | an object of class |
type | the type of parameter estimates that should be returned; structural parameters or fixed effects. Default is |
corrected,fixed | deprecated. |
... | other arguments. |
Value
The functioncoef.bife returns a named vector of estimates of the requested parameters.
See Also
Extract estimates of average partial effects
Description
coef.bifeAPEs is a generic function which extracts estimates of the average partial effects from objects returned byget_APEs.
Usage
## S3 method for class 'bifeAPEs'coef(object, ...)Arguments
object | an object of class |
... | other arguments. |
Value
The functioncoef.bifeAPEs returns a named vector of estimates of the average partial effects.
See Also
Extractbife fitted values
Description
fitted.bife is a generic function which extracts fitted values from an object returned bybife.
Usage
## S3 method for class 'bife'fitted(object, ...)Arguments
object | an object of class |
... | other arguments. |
Value
The functionfitted.bife returns a vector of fitted values.
See Also
Compute average partial effects for binary choice models with fixed effects
Description
get_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). Note that the command automatically determines which of the regressors are continuous or binary.
Remark: The routine currently does not allow to compute average partial effects based on functional forms like interactions and polynomials.
Note:apeff_bife is deprecated and will be removed soon.
Usage
get_APEs( object, n_pop = NULL, sampling_fe = c("independence", "unrestricted"), weak_exo = FALSE)apeff_bife(...)Arguments
object | an object of class |
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: |
sampling_fe | a string equal to |
weak_exo | logical indicating if some of the regressors are assumed to be weakly exogenous (e.g. predetermined). If object is returned by |
... | arguments passed to the deprecated function |
Value
The functionget_APEs returns a named list of class"bifeAPEs".
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.
Fernández-Val, I. (2009). "Fixed effects estimation of structural parameters and marginal effects in panel probit models". Journal of Econometrics 150(1), 71-85.
Fernández-Val, I. and M. Weidner (2018). "Fixed effects estimation of large-t panel data models". Annual Review of Economics, 10, 109-138.
Neyman, J. and E. L. Scott (1948). "Consistent estimates based on partially consistent observations". Econometrica, 16(1), 1-32.
Stammann, A., F. Heiss, and D. McFadden (2016). "Estimating Fixed Effects Logit Models with Large Panel Data". Working paper.
See Also
Examples
# Load 'psid' datasetlibrary(bife)dataset <- psid# Fit a static logit modelmod <- bife(LFP ~ I(AGE^2) + log(INCH) + KID1 + KID2 + KID3 + factor(TIME) | ID, dataset)summary(mod)# Compute average partial effectsmod_ape <- get_APEs(mod)summary(mod_ape)# Apply analytical bias correctionmod_bc <- bias_corr(mod)summary(mod_bc)# Compute bias-corrected average partial effectsmod_ape_bc <- get_APEs(mod_bc)summary(mod_ape_bc)Extract log-likelihood
Description
logLik.bife extracts the sum of the log-likelihood from an object returned bybife.
Usage
## S3 method for class 'bife'logLik(object, ...)Arguments
object | an object of class |
... | other arguments. |
Value
The functionlogLik.bife returns the sum of the log-likelihood.
See Also
Predict method forbife fits
Description
predict.bife is a generic function which obtains predictions from an object returned bybife.
Usage
## S3 method for class 'bife'predict( object, type = c("link", "response"), X_new = NULL, alpha_new = NULL, corrected = NULL, ...)Arguments
object | an object of class |
type | the type of prediction required. |
X_new | a data.frame or a regressor matrix for predictions. If not supplied predictions are based on the regressor matrix returned by the object |
alpha_new | a scalar or vector of fixed effects. If not supplied predictions are based on thevector of fixed effects returned by |
corrected | deprecated. |
... | other arguments |
Details
The model frame returned by the objectbife only includes individuals that were not dropped before the fitting process (due to perfect classification). The linear predictors of perfectly classified observations are equal to- Inf orInf whereas the predicted probabilities are equal to their response. In-sample predictions are only based on non-perfectly classified observations.
Ifalpha_new is supplied as a scalar the linear predictor is computed using the same value of the fixed effect for each observation. Ifalpha_new is supplied as a vector it has to be of same length as the rows of the corresponding regressor matrix. If onlyX_newis provided but notalpha_new, we use the average.
Value
The functionpredict.bife returns a vector of predictions.
See Also
Printbife
Description
print.bife is a generic function which displays some minimal information from objects returned bybife.
Usage
## S3 method for class 'bife'print(x, digits = max(3L, getOption("digits") - 3L), ...)Arguments
x | an object of class |
digits | unsigned integer indicating the number of decimal places. Default is |
... | other arguments. |
See Also
PrintbifeAPEs
Description
print.bifeAPEs is a generic function which displays some minimal information from objects returned byget_APEs.
Usage
## S3 method for class 'bifeAPEs'print(x, digits = max(3L, getOption("digits") - 3L), ...)Arguments
x | an object of class |
digits | unsigned integer indicating the number of decimal places. Default is |
... | other arguments. |
See Also
Printsummary.bife
Description
print.summary.bife is a generic function which displays summary statistics from objects returned bysummary.bife.
Usage
## S3 method for class 'summary.bife'print(x, digits = max(3L, getOption("digits") - 3L), ...)Arguments
x | an object of class |
digits | unsigned integer indicating the number of decimal places. Default is |
... | other arguments. |
See Also
Printsummary.bifeAPEs
Description
print.summary.bifeAPEs is a generic function which displays summary statistics from objects returned bysummary.bifeAPEs.
Usage
## S3 method for class 'summary.bifeAPEs'print(x, digits = max(3L, getOption("digits") - 3L), ...)Arguments
x | an object of class |
digits | unsigned integer indicating the number of decimal places. Default is |
... | other arguments. |
See Also
Female labor force participation
Description
The sample was obtained from the "Panel Study of Income Dynamics" andcontains information aboutN = 1461 women that were observed overT = 9 years.
Usage
psidFormat
A data frame with 13,149 rows:
- ID
individual identifier
- LFP
labor force participation
- KID1
# of kids aged between 0 and 2
- KID2
# of kids aged between 3 and 5
- KID3
# of kids aged between 6 and 17
- INCH
income husband
- AGE
age of woman
- TIME
time identifier
References
Hyslop, D. (1999). "State Dependence, Serial Correlation and Heterogeneity in Intertemporal Labor Force Participation of Married Women". Econometrica 67(6), 1255-1294.
Fernandez-Val, I. (2009). "Fixed effects estimation of structural parameters and marginal effects in panel probit models". Journal of Econometrics 150(1), 71-85.
See Also
Summarizing models of classbife
Description
Summary statistics for objects of class"bife".
Usage
## S3 method for class 'bife'summary(object, type = c("sp", "fe"), corrected = NULL, fixed = NULL, ...)Arguments
object | an object of class |
type | the type of parameter estimates the summary statistics are related to: structural parameters or fixed effects. Default is |
corrected,fixed | deprecated. |
... | other arguments. |
Value
Returns an object of class"summary.bife" which is a list of summary statistics ofobject.
See Also
Summarizing models of classbifeAPEs
Description
Summary statistics for objects of class"bifeAPEs".
Usage
## S3 method for class 'bifeAPEs'summary(object, ...)Arguments
object | an object of class |
... | other arguments. |
Value
Returns an object of class"summary.bifeAPEs" which is a list of summary statistics ofobject.
See Also
Extract estimates of the covariance matrix
Description
vcov.bife computes an estimate of the covariance matrix of the estimator of thestructural parameters from objects returned bybife. The estimate is obtainedusing the inverse of the negative Hessian after convergence.
Usage
## S3 method for class 'bife'vcov(object, ...)Arguments
object | an object of class |
... | other arguments. |
Value
The functionvcov.bife returns a named matrix of covariance estimates.
See Also
Extract estimates of the covariance matrix
Description
vcov.bifeAPEs computes an estimate of the covariance matrix of the estimator of theaverage partial parameters from objects returned byget_APEs.
Usage
## S3 method for class 'bifeAPEs'vcov(object, ...)Arguments
object | an object of class |
... | other arguments. |
Value
The functionvcov.bifeAPEs returns a named matrix of covariance estimates.