dummy-link

InteractiveFixedEffectModels

Interactive Fixed Effect Models — Bai (2009)

Readme

Build Status Coverage Status

Motivation

This package implements a novel, fast and robust algorithm to estimate interactive fixed effect models (Bai 2009).

Formally, denote T(i) and I(i)) the two categorical dimensions associated with observation i (typically time and id). This package estimates the set of coefficients β, of factors (f1, .., fr) and of loadings (λ1, ..., λr) in the model

minimization

Syntax

To estimate an interactive fixed effect model, one needs to specify a formula, a factor model with ife, and, eventually, a set of fixed effects with fe, a way to compute standard errors with vcov, and a weight variable with weights.

using DataFrames, RDatasets, InteractiveFixedEffectModels
df = dataset("plm", "Cigar")
df[:pState] =  pool(df[:State])
df[:pYear] =  pool(df[:Year])
regife(df, @model(Sales ~ Price, ife = (pState + pYear, 2), fe = pState, save = true))
#                      Linear Factor Model                      
#================================================================
#Number of obs:             1380  Degree of freedom:          199
#R2:                       0.976  R2 within:                0.435
#Iterations:                 436  Converged:                 true
#================================================================
#        Estimate Std.Error  t value Pr(>|t|) Lower 95% Upper 95%
#----------------------------------------------------------------
#Price  -0.425372 0.0141163 -30.1334    0.000 -0.453068 -0.397677
#================================================================
  • A typical formula is composed of one dependent variable and a set of regressors

    using RDatasets, DataFrames, InteractiveFixedEffectModels
    df = dataset("plm", "Cigar")
    

    When the only regressor is 0, fit fits a factor model

    Sales ~ 0
    

    Otherwise, fit fits a linear model with interactive fixed effects (Bai (2009))

    Sales ~ Price + Year
    
  • Interactive fixed effects are indicated with the keyword argument ife. Variables must be of type PooledDataVector. For instance, for a factor model with id variable State, time variable Year, and rank r equal to 2:

    df[:pState] =  pool(df[:State])
    df[:pYear] =  pool(df[:Year])
    ife = (pState + pYear, 2)
    
  • Fixed effects are indicated with the keyword argument fe. Use only the variables specified in the factor model. See FixedEffectModels.jl for more information

    fe = pState
    fe = pYear
    fe = pState + pYear
    
  • Standard errors are indicated with the keyword argument vcov

    vcov = robust()
    vcov = cluster(StatePooled)
    vcov = cluster(StatePooled, YearPooled)
    
  • weights are indicated with the keyword argument weights

    weights = Pop
    
  • method allows to choose between two algorithms:

    • levenberg_marquardt
    • dogleg
  • The option save = true saves a new dataframe storing residuals, factors, loadings and the eventual fixed effects. Importantly, the returned dataframe is aligned with the initial dataframe (rows not used in the estimation are simply filled with NA).

Local minimum vs global minimum

The algorithm can estimate models with missing observations per id x time, multiple observations per id x time, and weights.

However, in these cases, the optimization problem may have local minima. The algorithm tries to catch these cases, and, if need be, restart the optimization until the global minimum is reached. However I am not sure that all the cases are caught.

FAQ

Does the package estimate PCA / factor models?

Yes. Factor models are a particular case of interactive fixed effect models. Simply specify 0 as the lhs of the formula.

using DataFrames, RDatasets, InteractiveFixedEffectModels
df = dataset("plm", "Cigar")
df[:pState] =  pool(df[:State])
df[:pYear] =  pool(df[:Year])
regife(df, @model(Sales ~ 0, ife = (pState + pYear, 2), fe = pState, save = true))

Compared to the usual SVD method, the package estimates models with multiple (or missing) observations per id x time.

When should one use interactive fixed effects models?

Some litterature using this estimation procedure::

  • Eberhardt, Helmers, Strauss (2013) Do spillovers matter when estimating private returns to R&D?
  • Hagedorn, Karahan, Movskii (2015) Unemployment Benefits and Unemployment in the Great Recession: The Role of Macro Effects
  • Hagedorn, Karahan, Movskii (2015) The impact of unemployment benefit extensions on employment: the 2014 employment miracle?
  • Totty (2015) The Effect of Minimum Wages on Employment: A Factor Model Approach

How are standard errors computed?

Errors are obtained by regressing y on x and covariates of the form i.id#c.year and i.year#c.id. This way of computing standard errors is hinted in section 6 of of Bai (2009).

Does this command implement the bias correction term in Bai (2009)?

In presence of cross or time correlation beyond the factor structure, the estimate for beta is consistent but biased (see Theorem 3 in Bai 2009, which derives the correction term in special cases). However, this package does not implement any correction. You may want to check that your residuals are approximately i.i.d.

Related Packages

Install

Pkg.add("InteractiveFixedEffectModels")

First Commit

07/20/2015

Last Touched

about 2 months ago

Commits

108 commits

Used By: