Skip to content

Commit

Permalink
Merge pull request #126 from jmboehm/fix-midrule
Browse files Browse the repository at this point in the history
documentation for print_result and midrule fix
  • Loading branch information
jmboehm authored Aug 27, 2022
2 parents 8fed2ed + 6057af9 commit e13df11
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name = "RegressionTables"
uuid = "d519eb52-b820-54da-95a6-98e1306fdade"
authors = ["Johannes Boehm <[email protected]>"]
version = "0.5.7"
version = "0.5.8"

[deps]
Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
Expand Down
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ This package provides publication-quality regression tables for use with [FixedE

In its objective it is similar to (and heavily inspired by) the Stata command [`esttab`](http://repec.sowi.unibe.ch/stata/estout/esttab.html) and the R package [`stargazer`](https://cran.r-project.org/web/packages/stargazer/).

## Table of Contents

- [Installation](#Installation)
- [A brief demonstration](#a-brief-demonstration)
- [Function Reference](#function-reference)
- [Frequently Asked Questions](#frequently-asked-questions)

## Installation

To install the package, type in the Julia command prompt

```
Expand Down Expand Up @@ -144,7 +153,7 @@ R2 0.014 0.014
Printing of `StatsBase.RegressionModel`s is experimental; please file as issue if you encounter problems printing them.


## Options
## Function Reference

### Function Arguments
* `rr::Union{FixedEffectModel,DataFrames.TableRegressionModel}...` are the `FixedEffectModel`s from `FixedEffectModels.jl` (or `TableRegressionModel`s from `GLM.jl`) that should be printed. Only required argument.
Expand All @@ -164,6 +173,7 @@ Printing of `StatsBase.RegressionModel`s is experimental; please file as issue i
* `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`.
* `print_result` is a `Bool` that governs whether the table should be printed to `stdout`. Defaults to `true`.
* `standardize_coef` is a `Bool` that governs whether the table should show standardized coefficients. Note that this only works with `TableRegressionModel`s, 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.
Expand Down Expand Up @@ -211,3 +221,9 @@ to change the label for the row showing the number of observations in each regre
* `__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()`)

## Frequently Asked Questions

*What's the best way to render regression tables in Pluto.jl?*

Use `renderSettings = htmlOutput()` and `print_result = false`, and print the resulting `String` as `text/html`. [This page](https://jmboehm.github.io/regtables-pluto.jl.html) shows an example.
2 changes: 1 addition & 1 deletion src/rendersettings/html.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ function htmlOutput(outfile::String = "")
# toprule: just a spacer <tr>
toprule = "<tr><td style=\"padding:0.1cm\" colspan=\"100%\"></td></tr>"
# midrule: a <tr> with black border on bottom, and a <tr> spacer
midrule = "<tr style=\"border-bottom:1px solid black\"><td style=\"padding:0.1cm\" colspan=\"100%\"></td></tr><tr><td style=\"padding:0.1cm\" colspan=\"100%\"></td></tr>"
midrule = "<tr style=\"border-bottom:1px solid\"><td style=\"padding:0.1cm\" colspan=\"100%\"></td></tr><tr><td style=\"padding:0.1cm\" colspan=\"100%\"></td></tr>"
# bottomrule: a slightly larger spacer
bottomrule = "<tr><td style=\"padding:0.15cm\" colspan=\"100%\"></td></tr>"
headerrule = htmlHeaderRule
Expand Down
8 changes: 4 additions & 4 deletions test/tables/test1_reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<tr><td> <td colspan="3" style="padding:0.2cm; text-align:center; border-bottom:1px solid;">SepalLength</td> <td colspan="1" style="padding:0.2cm; text-align:center; border-bottom:1px solid;">SepalWidth</td> </td></tr>

<tr><td> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> (1) </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> (2) </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> (3) </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> (4) </td></tr>
<tr style="border-bottom:1px solid black"><td style="padding:0.1cm" colspan="100%"></td></tr><tr><td style="padding:0.1cm" colspan="100%"></td></tr>
<tr style="border-bottom:1px solid"><td style="padding:0.1cm" colspan="100%"></td></tr><tr><td style="padding:0.1cm" colspan="100%"></td></tr>
<tr><td>(Intercept) </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 6.526*** </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td></tr>
<tr><td> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> (0.479) </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td></tr>
<tr><td>SepalWidth </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> -0.223 </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 0.432*** </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 0.506*** </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td></tr>
Expand All @@ -15,12 +15,12 @@
<tr><td> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> (0.154) </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td></tr>
<tr><td>SepalLength </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> -0.313 </td></tr>
<tr><td> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> (0.239) </td></tr>
<tr style="border-bottom:1px solid black"><td style="padding:0.1cm" colspan="100%"></td></tr><tr><td style="padding:0.1cm" colspan="100%"></td></tr>
<tr style="border-bottom:1px solid"><td style="padding:0.1cm" colspan="100%"></td></tr><tr><td style="padding:0.1cm" colspan="100%"></td></tr>
<tr><td>Species </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> Yes </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> Yes </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> Yes </td></tr>
<tr><td>isSmall </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> Yes </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td></tr>
<tr style="border-bottom:1px solid black"><td style="padding:0.1cm" colspan="100%"></td></tr><tr><td style="padding:0.1cm" colspan="100%"></td></tr>
<tr style="border-bottom:1px solid"><td style="padding:0.1cm" colspan="100%"></td></tr><tr><td style="padding:0.1cm" colspan="100%"></td></tr>
<tr><td>Estimator </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> OLS </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> OLS </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> OLS </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> IV </td></tr>
<tr style="border-bottom:1px solid black"><td style="padding:0.1cm" colspan="100%"></td></tr><tr><td style="padding:0.1cm" colspan="100%"></td></tr>
<tr style="border-bottom:1px solid"><td style="padding:0.1cm" colspan="100%"></td></tr><tr><td style="padding:0.1cm" colspan="100%"></td></tr>
<tr><td><i>N</i> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 150 </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 150 </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 150 </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 150 </td></tr>
<tr><td><i>R<sup>2</sup></i> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 0.014 </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 0.863 </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 0.867 </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 0.080 </td></tr>
<tr><td>Adjusted <i>R<sup>2</sup></i> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 0.007 </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 0.860 </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 0.861 </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 0.055 </td></tr>
Expand Down
6 changes: 3 additions & 3 deletions test/tables/test2_reference.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<tr><td> <td colspan="2" style="padding:0.2cm; text-align:center; border-bottom:1px solid;">SepalLength</td> <td colspan="1" style="padding:0.2cm; text-align:center; border-bottom:1px solid;">Counts</td> </td></tr>

<tr><td> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> (1) </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> (2) </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> (3) </td></tr>
<tr style="border-bottom:1px solid black"><td style="padding:0.1cm" colspan="100%"></td></tr><tr><td style="padding:0.1cm" colspan="100%"></td></tr>
<tr style="border-bottom:1px solid"><td style="padding:0.1cm" colspan="100%"></td></tr><tr><td style="padding:0.1cm" colspan="100%"></td></tr>
<tr><td>(Intercept) </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 6.526*** </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 3.457*** </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 3.045*** </td></tr>
<tr><td> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> (0.479) </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> (0.309) </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> (0.126) </td></tr>
<tr><td>SepalWidth </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> -0.223 </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 0.399*** </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td></tr>
Expand All @@ -15,9 +15,9 @@
<tr><td> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> (0.202) </td></tr>
<tr><td>Outcome: C </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> -0.293 </td></tr>
<tr><td> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> (0.193) </td></tr>
<tr style="border-bottom:1px solid black"><td style="padding:0.1cm" colspan="100%"></td></tr><tr><td style="padding:0.1cm" colspan="100%"></td></tr>
<tr style="border-bottom:1px solid"><td style="padding:0.1cm" colspan="100%"></td></tr><tr><td style="padding:0.1cm" colspan="100%"></td></tr>
<tr><td>Estimator </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> OLS </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> OLS </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> NL </td></tr>
<tr style="border-bottom:1px solid black"><td style="padding:0.1cm" colspan="100%"></td></tr><tr><td style="padding:0.1cm" colspan="100%"></td></tr>
<tr style="border-bottom:1px solid"><td style="padding:0.1cm" colspan="100%"></td></tr><tr><td style="padding:0.1cm" colspan="100%"></td></tr>
<tr><td><i>N</i> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 150 </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 150 </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 9 </td></tr>
<tr><td><i>R<sup>2</sup></i> </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 0.014 </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> 0.707 </td><td style="padding:0.2em; padding-left:0.8em; padding-right:0.8em;"> </td></tr>
<tr><td style="padding:0.15cm" colspan="100%"></td></tr>
Expand Down

0 comments on commit e13df11

Please sign in to comment.