Learn R Programming

lfe (version 1.4-708)

getfe: Retrieve the group fixed effects

Description

Compute the group fixed effects, i.e. the dummy parameters, which were swept out during an estimation with felm.

Usage

getfe(obj,references=NULL,se=FALSE,
      method='kaczmarz',ef='ref',bN=100)

Arguments

Value

The function getfe computes and returns a data frame containing the group fixed effects. It has the columns c('effect','se','obs','comp','fe','idx')

  • effectis the estimated effect.
  • seis the standard error.
  • obsis the number of observations of this level.
  • compis the graph-theoretic component number, useful for interpreting the effects.
  • feis the name of factor.
  • idxis the level of the factor.

With the Kaczmarz-method it's possible to specify a different estimable function.

concept

Kaczmarz Method

Details

For the case with two factors (the fl-argument to felm), one reference in each connected component is adequate when interpreting the results.

For three or more factors, no such easy method is known; for the "cholesky" method- reference levels are found by analyzing the pivoted Cholesky-decomposition of a slightly perturbed system. The "kaczmarz" method provides no rank-deficiency analysis, it is assumed that the factors beyond the two first contribute nothing to the rank-deficiency, so one reference in each is used.

If there are more than two factors, only the first two will be used to report connected components. In this case, it is not known which graph theoretic concept may be used to analyze the rank-deficiency.

The standard errors returned by the Kaczmarz-method are bootstrapped, keeping the other coefficients (from felm) constant, i.e. they are from the variance when resampling the residuals.

Examples

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

## create individual and firm
id <- factor(sample(5000,length(x),replace=TRUE))
firm <- factor(sample(3000,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,se=TRUE)

## find some estimable functions, with standard errors, we don't get
## names so we must precompute some numerical indices in ef
idx <- match(c('id.5','id.6','firm.11','firm.12'),rownames(alpha))
alpha[idx,]
ef <- function(v,addnames) {
  w <- c(v[idx[[2]]]-v[idx[[1]]],v[idx[[4]]]+v[idx[[1]]],
         v[idx[[4]]]-v[idx[[3]]])
  if(addnames) names(w) <-c('id6-id5','f12+id5','f12-f11')
  w
}
getfe(est,ef=ef,se=TRUE)

summary(lm(y ~ x+x2+id+firm-1))

Run the code above in your browser using DataLab