Compute the variance of the fixed effect variance estimate
varvars(est, alpha = getfe(est), tol = 0.01, biascorrect = FALSE, lhs = NULL)
an object of class '"felm"', the result of a call to
felm(keepX=TRUE)
.
a data frame, the result of a call to getfe
.
numeric. The absolute tolerance for the bias-corrected correlation.
logical. Should the estimates be bias corrected?
character. Name of left hand side if multiple left hand sides.
varvars
returns a vector with a variance estimate for each
fixed effect variance. I.e. for the diagonal returned by
fevcov
.
With a model like 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.
Gaure, S. (2014), Correlation bias correction in two-way fixed-effects linear regression, Stat 3(1):379-390, 2014.
# 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