Learn R Programming

lfe (version 1.4-708)

btrap: Bootstrap standard errors for the group fixed effects

Description

Bootstrap standard errors for the group fixed effects which were swept out during an estimation with felm.

Usage

btrap(alpha, obj, N=100, ef=NULL,
      eps=getOption('lfe.eps'), threads=getOption('lfe.threads'))

Arguments

Value

A data-frame of the same size as alpha is returned, with standard errors filled in.

concept

Bootstrap

Details

The bootstrapping is done in parallel if threads > 1. btrap is run automatically from getfe if se=TRUE is specified.

Examples

Run this code
## create covariates
x <- rnorm(5000)
x2 <- rnorm(length(x))

## create individual and firm
id <- factor(sample(1000,length(x),replace=TRUE))
firm <- factor(sample(500,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 + G(id)+G(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
lfe:::is.estimable(ef,est$fe)

head(btrap(alpha,est,ef=ef))

Run the code above in your browser using DataLab