bccorr: Compute bias corrrected correlation between fixed effects
Description
With a model like 'y = X beta + D theta + F psi + epsilon', where 'D'
and 'F' are matrices with dummy encoded factors, one application of lfe is to
study the correlation 'cor(D theta, F psi)'. However, if we use
estimates for theta and psi, the resulting correlation is biased.
The function bccorr
computes a bias corrected correlation
as described in Gaure (2014).Usage
bccorr(est, alpha=getfe(est), corrfactors=1L:2L,
nocovar=is.null(est$X) && length(est$fe)==2,
tol=0.01, maxsamples=Inf)
Arguments
est
an object of class '"felm"', the result of a call to
felm(keepX=TRUE)
. alpha
a data frame, the result of a call to getfe
. corrfactors
integer or character vector of length 2. The factors to
correlate. The default is fine if there are only two factors in the model.
nocovar
logical. Assume no other covariates than the two
factors are present, or that they are uncorrelated with them.
tol
The absolute tolerance for the bias-corrected correlation.
maxsamples
Maximum number of samples for the trace sample means estimates
Value
bccorr
returns a named integer vector with the following fields:- corrthe bias corrected correlation.
- v1the bias corrected variance for the first factor specified
by
corrfactors
. - v2the bias corrected variance for the second factor.
- covthe bias corrected covariance between the two factors.
- d1the bias correction for the first factor.
- d2the bias correction for the second factor.
- d12the bias correction for covariance.
- The bias corrections have been subtracted from the bias estimates.
E.g. v2 = v2' - d2, where v2' is the biased variance.
concept
Limited Mobility BiasDetails
The bias expressions from Andrews et al. are of the form 'tr(A B^{-1} C)'
where A, B, and C are matrices too large to be handled
directly. bccorr
estimates the trace by using the formula $tr(M) = E(x^t M x)$
where x is a vector with coordinates drawn uniformly from the set {-1,1}.
More specifically, the expectation is estimated by
sample means, i.e. in each sample a vector x is drawn, the
equation 'Bv = Cx' is solved by a conjugate gradient method, and the
real number $x^t Av$ is computed. There are three bias corrections, for the variances of D theta (vD) and
F psi (vF), and their covariance (vDF).The correlation is computed as
rho <- vDF/sqrt(vD*vF)
. The variances are estimated to a
relative tolerance specified by the argument tol
. The covariance
bias is estimated to an absolute tolerance in the correlation rho
(conditional on the already bias corrected vD and vF) specified by
tol
. The CG algortithm does not need to be exceedingly precise,
it is terminated when the solution reaches a precision which is
sufficient for the chosen precision in vD, vF, vDF
.
References
Gaure, S. (2014), Correlation bias correction in two-way
fixed-effects linear regression, Stat 3(1), 2014, 379-390.