Learn R Programming

lfe (version 1.1-427)

getfe: Retrieve the group fixed effects

Description

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

Usage

getfe(obj)

Arguments

Value

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.

Examples

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

## create individual and firm
id <- factor(sample(20,length(x),replace=TRUE))
firm <- factor(sample(8,length(x),replace=TRUE,prob=c(2,rep(1,7))))

## 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))

## make a data frame
dset <- data.frame(y,x,x2,id,firm)

## estimate and print result
est <- felm(y ~ x+x2,fl=list(id=id,firm=firm),data=dset)
summary(est)

## extract the group effects
getfe(est)

## compare with an ordinary lm
summary(lm(y ~ x+x2+id+firm-1,data=dset))

## compare with lmer
if(require(lme4)) print(coef(lmer(y ~ x + x2 + (1|id) + (1|firm),data=dset)))

Run the code above in your browser using DataLab