FE_decompo: Decomposition of fixed-effects weights

View source: R/FEdecompo_simple.R

FE_decompoR Documentation

Decomposition of fixed-effects weights

Description

Decomposition of fixed-effects weights

Usage

FE_decompo(
  data,
  y_var = "y",
  time.index = "Time",
  treat = "tr",
  unit.index = "unit",
  covar = NULL,
  fixed_effects = c("time", "unit", "both"),
  by = unit.index
)

Arguments

data

A data frame containing the variables of itnerest, should have names y_var, treat, time.index and unit.index

y_var

The name of the y variable

time.index

The name of the variable describing the time index (date, year, etc)

treat

The name of the treatment variable.

unit.index

The name of the units (individual, county, household, etc).

covar

covariate to include This will use the values indicated in time.index and unit.index

fixed_effects

The fixed effects to include, either time, unit ot both.

by

over which dimension to do it?

Examples

library(lfe)
 dat_sim_1 <- sim_dat(N=100, Time = 5)
coef_FE_time <- coef(felm(y~tr|Time, data = dat_sim_1))
coef_FE_unit <- coef(felm(y~tr|unit, data = dat_sim_1))

coefs_by_Y <- FE_decompo(data=dat_sim_1,
                         treat = "tr",
                         by = "Time",
                         fixed_effects = "time")
coefs_by_U <- FE_decompo(data=dat_sim_1,
                         treat = "tr",
                         by = "unit",
                         fixed_effects = "unit")
with(coefs_by_Y, weighted.mean(treat_coef, treat_weight))
coef_FE_time
with(coefs_by_U, weighted.mean(treat_coef, treat_weight))
coef_FE_unit


MatthieuStigler/multiDiff documentation built on Oct. 21, 2023, 8:13 a.m.