Description Usage Arguments Details Value Examples
Bootstrap standard errors for the group fixed effects which were swept out
during an estimation with felm
.
1 2 3 4 5 6 7 8 9 10 11 |
alpha |
data frame returned from |
obj |
object of class |
N |
integer. The number of bootstrap iterations |
ef |
function. An estimable function such as in |
eps |
double. Tolerance for centering, as in getfe |
threads |
integer. The number of threads to use |
robust |
logical. Should heteroskedastic standard errors be estimated? |
cluster |
logical or factor. Estimate clustered standard errors. |
lhs |
character vector. Specify which left hand side if |
The bootstrapping is done in parallel if threads > 1
.
btrap
is run automatically from getfe
if
se=TRUE
is specified. To save some overhead, the individual
iterations are grouped together, the memory available for this grouping is
fetched with getOption('lfe.bootmem')
, which is initialized upon
loading of lfe to options(lfe.bootmem=500)
(MB).
If robust=TRUE
, heteroskedastic robust standard errors are estimated.
If robust=FALSE
and cluster=TRUE
, clustered standard errors
with the cluster specified to felm()
are estimated. If cluster
is a factor, it is used for the cluster definition. cluster may
also
be a list of factors.
A data-frame of the same size as alpha is returned, with standard errors filled in.
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 27 28 29 30 31 32 33 34 35 36 37 38 39 | oldopts <- options(lfe.threads=2)
## create covariates
x <- rnorm(3000)
x2 <- rnorm(length(x))
## create individual and firm
id <- factor(sample(700,length(x),replace=TRUE))
firm <- factor(sample(300,length(x),replace=TRUE))
## effects
id.eff <- rlnorm(nlevels(id))
firm.eff <- rexp(nlevels(firm))
## left hand side
y <- x + 0.25*x2 + id.eff[id] + firm.eff[firm] + rnorm(length(x))
## estimate and print result
est <- felm(y ~ x+x2 | id + firm)
summary(est)
## extract the group effects
alpha <- getfe(est)
head(alpha)
## bootstrap standard errors
head(btrap(alpha,est))
## bootstrap some differences
ef <- function(v,addnames) {
w <- c(v[2]-v[1],v[3]-v[2],v[3]-v[1])
if(addnames) {
names(w) <-c('id2-id1','id3-id2','id3-id1')
attr(w,'extra') <- list(note=c('line1','line2','line3'))
}
w
}
# check that it's estimable
is.estimable(ef,est$fe)
head(btrap(alpha,est,ef=ef))
options(oldopts)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.