varvars: Compute the variance of the fixed effect variance estimate

Description Usage Arguments Details Value Note References See Also Examples

View source: R/bccorr.R

Description

Compute the variance of the fixed effect variance estimate

Usage

1
varvars(est, alpha = getfe(est), tol = 0.01, biascorrect = FALSE, lhs = NULL)

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.

tol

numeric. The absolute tolerance for the bias-corrected correlation.

biascorrect

logical. Should the estimates be bias corrected?

lhs

character. Name of left hand side if multiple left hand sides.

Details

With a model like y = Xβ + Dθ + Fψ + ε, where D and F are matrices with dummy encoded factors, one application of lfe is to study the variances var(Dθ), var(Fψ) and covariances cov(Dθ, Fψ). The function fevcov computes bias corrected variances and covariances. However, these variance estimates are still random variables for which fevcov only estimate the expectation. The function varvars estimates the variance of these estimates.

This function returns valid results only for normally distributed residuals. Note that the estimates for the fixed effect variances from fevcov are not normally distributed, but a sum of chi-square distributions which depends on the eigenvalues of certain large matrices. We do not compute that distribution. The variances returned by varvars can therefore not be used directly to estimate confidence intervals, other than through coarse methods like the Chebyshev inequality. These estimates only serve as a rough guideline as to how wrong the variance estimates from fevcov might be.

Like the fixed effect variances themselves, their variances are also biased upwards. Correcting this bias can be costly, and is therefore by default switched off.

The variances tend to zero with increasing number of observations. Thus, for large datasets they will be quite small.

Value

varvars returns a vector with a variance estimate for each fixed effect variance. I.e. for the diagonal returned by fevcov.

Note

The tol argument specifies the tolerance as in fevcov. Note that if est is the result of a call to felm with keepX=FALSE (the default), the variances will be estimated as if the covariates X are independent of the factors. There is currently no function available for estimating the variance of the covariance estimates from fevcov.

The cited paper does not contain the expressions for the variances computed by varvars (there's a 10 page limit in that journal), though they can be derived in the same fashion as in the paper, with the formula for the variance of a quadratic form.

References

Gaure, S. (2014), Correlation bias correction in two-way fixed-effects linear regression, Stat 3(1):379-390, 2014.

See Also

bccorr fevcov

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
x <- rnorm(500)
x2 <- rnorm(length(x))

## create individual and firm
id <- factor(sample(40,length(x),replace=TRUE))
firm <- factor(sample(30,length(x),replace=TRUE,prob=c(2,rep(1,29))))
foo <- factor(sample(20,length(x),replace=TRUE))
## effects
id.eff <- rnorm(nlevels(id))
firm.eff <- rnorm(nlevels(firm))
foo.eff <- rnorm(nlevels(foo))
## left hand side
id.m <- id.eff[id]
firm.m <- 2*firm.eff[firm]
foo.m <- 3*foo.eff[foo]
y <- x + 0.25*x2 + id.m + firm.m + foo.m + rnorm(length(x))

# make a data frame
fr <- data.frame(y,x,x2,id,firm,foo)
## estimate and print result
est <- felm(y ~ x+x2|id+firm+foo, data=fr, keepX=TRUE)
alpha <- getfe(est)
# estimate the covariance matrix of the fixed effects
fevcov(est, alpha)
# estimate variances of the diagonal
varvars(est, alpha)

sgaure/lfe documentation built on Dec. 27, 2019, 8:06 a.m.