All Projects → jmboehm → RegressionTables.jl

jmboehm / RegressionTables.jl

Licence: MIT license
Journal-style regression tables

Programming Languages

julia
2034 projects
HTML
75241 projects
TeX
3793 projects

Projects that are alternatives of or similar to RegressionTables.jl

Appelpy
Applied Econometrics Library for Python
Stars: ✭ 136 (+65.85%)
Mutual labels:  regression, economics
Fixedeffectmodels.jl
Fast Estimation of Linear Models with IV and High Dimensional Categorical Variables
Stars: ✭ 132 (+60.98%)
Mutual labels:  regression, economics
R4Econ
R Code Examples Multi-dimensional/Panel Data
Stars: ✭ 16 (-80.49%)
Mutual labels:  regression, economics
Microeconometrics.jl
Microeconometric estimation in Julia
Stars: ✭ 30 (-63.41%)
Mutual labels:  regression, economics
imbalanced-regression
[ICML 2021, Long Talk] Delving into Deep Imbalanced Regression
Stars: ✭ 425 (+418.29%)
Mutual labels:  regression
akshare
AKShare is an elegant and simple financial data interface library for Python, built for human beings! 开源财经数据接口库
Stars: ✭ 5,155 (+6186.59%)
Mutual labels:  economics
piven
Official implementation of the paper "PIVEN: A Deep Neural Network for Prediction Intervals with Specific Value Prediction" by Eli Simhayev, Gilad Katz and Lior Rokach
Stars: ✭ 26 (-68.29%)
Mutual labels:  regression
BAS
BAS R package https://merliseclyde.github.io/BAS/
Stars: ✭ 36 (-56.1%)
Mutual labels:  regression
ridge
CRAN R Package: Ridge Regression with automatic selection of the penalty parameter
Stars: ✭ 17 (-79.27%)
Mutual labels:  regression
wink-statistics
Fast & numerically stable statistical analysis
Stars: ✭ 36 (-56.1%)
Mutual labels:  regression
Econ-Data-Science
Articles/ Journals and Videos related to Economics📈 and Data Science 📊
Stars: ✭ 102 (+24.39%)
Mutual labels:  economics
ImVisible
ImVisible: Pedestrian Traffic Light Dataset, Neural Network, and Mobile Application for the Visually Impaired (CAIP '19, ICCVW'19)
Stars: ✭ 32 (-60.98%)
Mutual labels:  regression
sl3
💪 🤔 Modern Super Learning with Machine Learning Pipelines
Stars: ✭ 93 (+13.41%)
Mutual labels:  regression
bacondecomp
Bacon-Goodman decomposition for differences-in-differences with variation in treatment timing.
Stars: ✭ 36 (-56.1%)
Mutual labels:  economics
HurdleDMR.jl
Hurdle Distributed Multinomial Regression (HDMR) implemented in Julia
Stars: ✭ 19 (-76.83%)
Mutual labels:  regression
onelearn
Online machine learning methods
Stars: ✭ 14 (-82.93%)
Mutual labels:  regression
econ5170
Econ5170@CUHK: Computational Methods in Economics (2020 Spring).
Stars: ✭ 127 (+54.88%)
Mutual labels:  economics
LinearityIQA
[official] Norm-in-Norm Loss with Faster Convergence and Better Performance for Image Quality Assessment (ACM MM 2020)
Stars: ✭ 73 (-10.98%)
Mutual labels:  regression
quantgov
The QuantGov Library
Stars: ✭ 21 (-74.39%)
Mutual labels:  economics
DichotomyTests
Dichotomy Tests provides interesting tests that show you how inclined you are toward certain philosophical, psychological or political views. Each test tries to discover your preferred beliefs and will attempt to accurately position you along numerous dichotomic axes.
Stars: ✭ 78 (-4.88%)
Mutual labels:  economics

Build Status codecov.io DOI

RegressionTables.jl

This package provides publication-quality regression tables for use with FixedEffectModels.jl and GLM.jl, as well as any package that implements the RegressionModel abstraction.

In its objective it is similar to (and heavily inspired by) the Stata command esttab and the R package stargazer.

To install the package, type in the Julia command prompt

] add RegressionTables

A brief demonstration

using RegressionTables, DataFrames, FixedEffectModels, RDatasets

df = dataset("datasets", "iris")
df[!,:SpeciesDummy] = categorical(df[!,:Species])

rr1 = reg(df, @formula(SepalLength ~ SepalWidth + fe(SpeciesDummy)))
rr2 = reg(df, @formula(SepalLength ~ SepalWidth + PetalLength + fe(SpeciesDummy)))
rr3 = reg(df, @formula(SepalLength ~ SepalWidth + PetalLength + PetalWidth + fe(SpeciesDummy)))
rr4 = reg(df, @formula(SepalWidth ~ SepalLength + PetalLength + PetalWidth + fe(SpeciesDummy)))

regtable(rr1,rr2,rr3,rr4; renderSettings = asciiOutput())

yields

----------------------------------------------------------
                         SepalLength            SepalWidth
               ------------------------------   ----------
                    (1)        (2)        (3)          (4)
----------------------------------------------------------
SepalWidth     0.804***   0.432***   0.496***             
                (0.106)    (0.081)    (0.086)             
PetalLength               0.776***   0.829***      -0.188*
                           (0.064)    (0.069)      (0.083)
PetalWidth                            -0.315*     0.626***
                                      (0.151)      (0.123)
SepalLength                                       0.378***
                                                   (0.066)
----------------------------------------------------------
SpeciesDummy        Yes        Yes        Yes          Yes
----------------------------------------------------------
Estimator           OLS        OLS        OLS          OLS
----------------------------------------------------------
N                   150        150        150          150
R2                0.726      0.863      0.867        0.635
----------------------------------------------------------

LaTeX output can be generated by using

regtable(rr1,rr2,rr3,rr4; renderSettings = latexOutput())

which yields

\begin{tabular}{lrrrr}
\toprule
             & \multicolumn{3}{c}{SepalLength} & \multicolumn{1}{c}{SepalWidth} \\
\cmidrule(lr){2-4} \cmidrule(lr){5-5}
             &      (1) &      (2) &       (3) &                            (4) \\
\midrule
SepalWidth   & 0.804*** & 0.432*** &  0.496*** &                                \\
             &  (0.106) &  (0.081) &   (0.086) &                                \\
PetalLength  &          & 0.776*** &  0.829*** &                        -0.188* \\
             &          &  (0.064) &   (0.069) &                        (0.083) \\
PetalWidth   &          &          &   -0.315* &                       0.626*** \\
             &          &          &   (0.151) &                        (0.123) \\
SepalLength  &          &          &           &                       0.378*** \\
             &          &          &           &                        (0.066) \\
\midrule
SpeciesDummy &      Yes &      Yes &       Yes &                            Yes \\
\midrule
Estimator    &      OLS &      OLS &       OLS &                            OLS \\
\midrule
$N$          &      150 &      150 &       150 &                            150 \\
$R^2$        &    0.726 &    0.863 &     0.867 &                          0.635 \\
\bottomrule
\end{tabular}

Similarly, HTML tables can be created with htmlOutput().

Send the output to a text file by passing the destination file string to the asciiOutput(), latexOutput(), or htmlOutput() functions:

regtable(rr1,rr2,rr3,rr4; renderSettings = latexOutput("myoutputfile.tex"))

then use \input in LaTeX to include that file in your code. Be sure to use the booktabs package:

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{table}
\label{tab:mytable}
\input{myoutputfile}
\end{table}

\end{document}

regtable() can also print TableRegressionModel's from GLM.jl (and output from other packages that produce TableRegressionModel's):

using GLM

dobson = DataFrame(Counts = [18.,17,15,20,10,20,25,13,12],
    Outcome = categorical(repeat(["A", "B", "C"], outer = 3)),
    Treatment = categorical(repeat(["a","b", "c"], inner = 3)))
lm1 = fit(LinearModel, @formula(SepalLength ~ SepalWidth), df)
gm1 = fit(GeneralizedLinearModel, @formula(Counts ~ 1 + Outcome + Treatment), dobson,
                  Poisson())

regtable(rr1,lm1,gm1; renderSettings = asciiOutput())

yields

---------------------------------------------
                   SepalLength        Counts
               -------------------   --------
                    (1)        (2)        (3)
---------------------------------------------
(Intercept)    6.526***   6.526***   3.045***
                (0.479)    (0.479)    (0.171)
SepalWidth       -0.223     -0.223           
                (0.155)    (0.155)           
Outcome: B                             -0.454
                                      (0.202)
Outcome: C                             -0.293
                                      (0.193)
Treatment: b                            0.000
                                      (0.200)
Treatment: c                            0.000
                                      (0.200)
---------------------------------------------
Estimator           OLS        OLS         NL
---------------------------------------------
N                   150        150          9
R2                0.014      0.014           
---------------------------------------------

Printing of StatsBase.RegressionModels is experimental; please file as issue if you encounter problems printing them.

Options

Function Arguments

  • rr::Union{FixedEffectModel,DataFrames.TableRegressionModel}... are the FixedEffectModels from FixedEffectModels.jl (or TableRegressionModels from GLM.jl) that should be printed. Only required argument.

  • regressors is a Vector of regressor names (Strings) that should be shown, in that order. Defaults to an empty vector, in which case all regressors will be shown.

  • fixedeffects is a Vector of FE names (Strings) that should be shown, in that order. Defaults to an empty vector, in which case all FE's will be shown. Note that strings need to match the displayed label exactly, otherwise they will not be shown.

  • labels is a Dict that contains displayed labels for variables (strings) and other text in the table. If no label for a variable is found, it default to variable names. See documentation for special values.

  • estimformat is a String that describes the format of the estimate. Defaults to "%0.3f".

  • estim_decoration is a Function that takes the formatted string and the p-value, and applies decorations (such as the beloved stars). Defaults to (* p<0.05, ** p<0.01, *** p<0.001).

  • statisticformat is a String that describes the format of the number below the estimate (se/t). Defaults to "%0.4f".

  • below_statistic is a Symbol that describes a statistic that should be shown below each point estimate. Recognized values are :blank, :se, :tstat, and :none. :none suppresses the line. Defaults to :se.

  • below_decoration is a Function that takes the formatted statistic string, and applies a decorations. Defaults to round parentheses.

  • regression_statistics is a Vector of Symbols that describe statistics to be shown at the bottom of the table. Recognized symbols are :nobs, :r2, :r2_a, :r2_within, :f, :p, :f_kp, :p_kp, and :dof. Defaults to [:nobs, :r2].

  • custom_statistics is a NamedTuple that takes user specified statistics to be shown just above regression_statistics. By default each statistic will be labelled by its key (e.g. __LABEL_STATISTIC_mystat__ for the statistic mystat). Defaults to missing. See test/RegressionTables.jl for an example of how to use this.

  • number_regressions is a Bool that governs whether regressions should be numbered. Defaults to true.

  • number_regressions_decoration is a Function that governs the decorations to the regression numbers. Defaults to s -> "($s)".

  • groups is a Vector of labels used to group regressions. This can be useful if results are shown for different data sets or sample restrictions. Defaults to [].

  • print_fe_section is a Bool that governs whether a section on fixed effects should be shown. Defaults to true.

  • print_estimator_section is a Bool that governs whether to print a section on which estimator (OLS/IV) is used. Defaults to true.

  • standardize_coef is a Bool that governs whether the table should show standardized coefficients. Note that this only works with TableRegressionModels, and that only coefficient estimates and the below_statistic are being standardized (i.e. the R^2 etc still pertain to the non-standardized regression).

  • out_buffer is an IOBuffer that the output gets sent to (unless an output file is specified, in which case the output is only sent to the file).

  • renderSettings::RenderSettings is a RenderSettings composite type that governs how the table should be rendered. Standard supported types are ASCII (via asciiOutput(outfile::String)) and LaTeX (via latexOutput(outfile::String)). If no argument to these two functions are given, the output is sent to STDOUT. Defaults to ASCII with STDOUT.

  • transform_labels is a function or a Dict that is used to transform labels. Defaults to identity.

    Some common use cases can be achieved by passing a Symbol instead: :latex, :ampersand, :underscore, :underscore2space. For illustration, here are the three ways to escape forbidden LaTeX characters.

    # Option 1
    regtable(rr; renderSettings = latexOutput(), transform_labels = :latex)
    # Option 2
    repl_dict = Dict("&" => "\\&", "%" => "\\%", "\$" => "\\\$", "#" => "\\#", "_" => "\\_", "{" => "\\{", "}" => "\\}")
    regtable(rr; renderSettings = latexOutput(), transform_labels = repl_dict)
    # Option 3
    function transform(s, repl_dict=repl_dict)
        for (old, new) in repl_dict
            s = replace.(s, Ref(old => new))
        end
        s
    end
    regtable(rr; renderSettings = latexOutput(), transform_labels = transform)

Label Codes

The following is the exhaustive list of strings that govern the output of labels. Use e.g.

labels = Dict("__LABEL_STATISTIC_N__" => "Number of observations")

to change the label for the row showing the number of observations in each regression.

  • __LABEL_ESTIMATOR__ (default: "Estimator")

  • __LABEL_ESTIMATOR_OLS__ (default: "OLS")

  • __LABEL_ESTIMATOR_IV__ (default: "IV")

  • __LABEL_ESTIMATOR_NL__ (default: "NL")

  • __LABEL_FE_YES__ (default: "Yes")

  • __LABEL_FE_NO__ (default: "")

  • __LABEL_STATISTIC_N__ (default: "N" in asciiOutput())

  • __LABEL_STATISTIC_R2__ (default: "R2" in asciiOutput())

  • __LABEL_STATISTIC_R2_A__ (default: "Adjusted R2" in asciiOutput())

  • __LABEL_STATISTIC_R2_WITHIN__ (default: "Within-R2" in asciiOutput())

  • __LABEL_STATISTIC_F__ (default: "F" in asciiOutput())

  • __LABEL_STATISTIC_P__ (default: "F-test p value" in asciiOutput())

  • __LABEL_STATISTIC_F_KP__ (default: "First-stage F statistic" in asciiOutput())

  • __LABEL_STATISTIC_P_KP__ (default: "First-stage p value" in asciiOutput())

  • __LABEL_STATISTIC_DOF__ (default: "Degrees of Freedom" in asciiOutput())

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].