Learn R Programming

lfe (version 2.8-3)

varvars: Compute the variance of the fixed effect variance estimate

Description

Compute the variance of the fixed effect variance estimate

Usage

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.

Value

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

Details

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 variances \(var(D\theta)\), \(var(F\psi)\) and covariances \(cov(D\theta, F\psi)\). 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.

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

Run this code
# NOT RUN {
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)

# }

Run the code above in your browser using DataLab