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.
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"
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 likelm
orfelm
and keeps in memory most of the julia outputreg_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
- For standard estimation: FixedEffectModels.Rmd
- For IV and Interactive FE: OtherFEModels.Rmd
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
.