Learn R Programming

lfe (version 1.2-452)

getfe: Retrieve the group fixed effects

Description

Compute the group fixed effects which were swept out during an estimation with felm.

Usage

getfe(obj,references=NULL,se=FALSE,method='kaczmarz')

Arguments

Value

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

  • effectis the estimated effect.
  • 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.

The 'effect' column is set to 'zero' for the levels which have been used as reference levels.

For method 'kaczmarz', references are not set to 0, but the smallest norm solution is returned.

concept

Kaczmarz Method

Details

For the case with two factors (the fl-argument to felm), one reference in each connection component is chosen automatically. For three or more factors, no such easy method is known, reference levels are found by analyzing the pivoted Cholesky-decomposition of a slightly perturbed system.

Examples

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

## create individual and firm
id <- factor(sample(3000,length(x),replace=TRUE))
firm <- factor(sample(1500,length(x),replace=TRUE,prob=c(2,rep(1,1499))))

## 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
cat(date(),'Start lfe estimation
')
est <- felm(y ~ x+x2 + G(id)+G(firm))
summary(est)
## extract the group effects
alpha <- getfe(est)
cat(date(),'Done
')
cat(date(),'Compare with lm estimation\n')
lmsum <- summary(lm(y ~ x+x2+id+firm-1))
cat(date(),'Done\n')

Run the code above in your browser using DataLab