Skip to content

FixedEffects/FixedEffectjlr

Folders and files

NameName
Last commit message
Last commit date

Latest commit

author
Erik Loualiche
Jul 25, 2018
6f576eb · Jul 25, 2018

History

43 Commits
Jul 25, 2018
Jul 24, 2018
Mar 30, 2018
Mar 30, 2018
Jul 24, 2018
Mar 29, 2018
Mar 27, 2018
Mar 30, 2018
Jul 16, 2018
Mar 30, 2018
Mar 22, 2018
Mar 26, 2018
Mar 30, 2018
Jul 25, 2018

Repository files navigation

R interface for Fixed Effect Models

Build Status codecov

This package uses the FixedEffectModels.jl julia package and the JuliaCall R library to estimate large fixed effects models in R.

It is a substitute to the felm R package. It is usually faster (see benchmarks) and converges more robustly. This uses the JuliaCall library to pass datasets into julia and process them.

The package is very preliminary, so please use it and let me know if you run into issues!

Thanks to Matthieu and Changcheng.

Usage

Install the package directly from github

devtools::install_github("eloualiche/FixedEffectjlr")

First setup julia to work within R with JuliaCall

library(FixedEffectjlr)
JULIA_HOME <- "/Applications/Julia-0.6.app/Contents/Resources/julia/bin/"
FixedEffect_setup(JULIA_HOME)

To run a regression with fixed effects

df <- Ecdat::Cigar
reg_res <- FixedEffect(df,
  lhs = "sales", rhs = "ndi",
  fe      = "state + year",
  weights = "pop",
  vcov    = "cluster(state)")
  
#                          Fixed Effect Model
# =====================================================================
# Number of obs:               1380   Degrees of freedom:            31
# R2:                         0.804   R2 within:                  0.139
# F-Statistic:              13.3481   p-value:                    0.000
# Iterations:                     6   Converged:                   true
# =====================================================================
#         Estimate  Std.Error  t value Pr(>|t|)   Lower 95%   Upper 95%
# ---------------------------------------------------------------------
# ndi  -0.00526264 0.00144043 -3.65351    0.000 -0.00808837 -0.00243691
# =====================================================================  
  • For now the functions takes as inputs different strings for independent variable, regressors and fixed effects instead of a formula as in felm.
  • FixedEffectModels.jl accepts arbitrary number of fixed effects as well as interaction of categorical variables:
fe = "year + firm"
fe = "year:industry"
  • Standard errors are either adjusted for heteroscedasticity, robust or clustered by categories:
vcov = "robust"
vcov = "cluster(industry + year)"
  • It is also possible to add weights:
weights = "pop"

Output

The functions prints out a table that is generated directly from julia. Moreover it collects information about the regressions and output two lists:

  • reg_res$results should eventually become a regression class like lm or felm and keeps in memory most of the julia output
  • reg_res$summary is most useful to create regression tables and keep regressors, standard errors, etc...
  • reg_res$summary$coeftest for a coeftest object, to be used directly in stargazer

Vignettes

Prerequisite:

The package requires a working installation of julia (last tested with julia 0.6.4)

Thanks to Changcheng for developing JuliaCall.

Thanks to Matthieu for all his packages!

See other packages built on JuliaCall: convexjlr and ipoptjlr.