Download the notebook here

How to generate publication quality tables

estimagic helps you generate publication quality html and LaTex tables, given a list of estimation results.

Set up

[1]:
import io
import re
from collections import namedtuple
from copy import copy
from copy import deepcopy

import estimagic.visualization.estimation_table as et
import numpy as np
import pandas as pd
import statsmodels.api as sm
from estimagic.config import TEST_DIR
from IPython.core.display import HTML
from IPython.core.display import Latex
[2]:
# Load dataset
df = pd.read_csv(TEST_DIR / "visualization" / "diabetes.csv", index_col=0)
[3]:
df.head()
[3]:
Age Sex BMI ABP S1 S2 S3 S4 S5 S6 target
0 0.038076 0.050680 0.061696 0.021872 -0.044223 -0.034821 -0.043401 -0.002592 0.019908 -0.017646 151.0
1 -0.001882 -0.044642 -0.051474 -0.026328 -0.008449 -0.019163 0.074412 -0.039493 -0.068330 -0.092204 75.0
2 0.085299 0.050680 0.044451 -0.005671 -0.045599 -0.034194 -0.032356 -0.002592 0.002864 -0.025930 141.0
3 -0.089063 -0.044642 -0.011595 -0.036656 0.012191 0.024991 -0.036038 0.034309 0.022692 -0.009362 206.0
4 0.005383 -0.044642 -0.036385 0.021872 0.003935 0.015596 0.008142 -0.002592 -0.031991 -0.046641 135.0
[4]:
# Fit regressions
est = sm.OLS(endog=df["target"], exog=sm.add_constant(df[df.columns[0:4]])).fit()
est2 = sm.OLS(endog=df["target"], exog=sm.add_constant(df[df.columns[0:6]])).fit()

The estimation results can be passed as statsmodels regression results, or as a tuple with attributes params (pandas DataFrame), with parameter values, standard errors and/or confidence intervals and p-values, and info (dict) with summary statistics of the model.

[5]:
# Extract `params` and `info`
namedtuplee = namedtuple("namedtuplee", "params info")
est3 = namedtuplee(
    params=et._extract_params_from_sm(est),
    info={**et._extract_info_from_sm(est)},
)

# Remove redundant information
del est3.info["df_model"]
del est3.info["df_resid"]

The resulting dictionary contains all the information we need:

[6]:
est3[0]
[6]:
value pvalue standard_error ci_lower ci_upper
const 152.133484 2.048808e-193 2.852749 146.526671 157.740298
Age 37.241211 5.616557e-01 64.117433 -88.775663 163.258084
Sex -106.577520 8.695658e-02 62.125062 -228.678572 15.523532
BMI 787.179313 5.345260e-29 65.424126 658.594255 915.764371
ABP 416.673772 4.245663e-09 69.494666 280.088446 553.259097
[7]:
est3[1]
[7]:
{'rsquared': 0.40026108237713975,
 'rsquared_adj': 0.3947714813005003,
 'fvalue': 72.912599073987,
 'f_pvalue': 2.7007228809503304e-47,
 'dependent_variable': 'target',
 'resid_std_err': 59.97560860753489,
 'n_obs': 442.0}
[8]:
# Make copy of estimation results
est4 = {}
est4["params"] = deepcopy(est3.params)
est4["info"] = deepcopy(est3.info)

est5 = {}
est5["params"] = deepcopy(est3.params)
est5["info"] = deepcopy(est3.info)

Basics

Basic features include custom title and custom names for models, columns, index and parameters.

Basic table, without title

[9]:
ex_html = et.estimation_table([est, est2, est3, est4, est5], return_type="html")
HTML(ex_html)
[9]:
(1) (2) (3) (4) (5)
const 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$
(2.85) (2.85) (2.85) (2.85) (2.85)
Age 37.24$^{ }$ 24.7$^{ }$ 37.24$^{ }$ 37.24$^{ }$ 37.24$^{ }$
(64.12) (65.41) (64.12) (64.12) (64.12)
Sex -106.58$^{* }$ -82.86$^{ }$ -106.58$^{* }$ -106.58$^{* }$ -106.58$^{* }$
(62.13) (64.85) (62.13) (62.13) (62.13)
BMI 787.18$^{*** }$ 789.74$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$
(65.42) (66.89) (65.42) (65.42) (65.42)
ABP 416.67$^{*** }$ 397.58$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$
(69.49) (70.87) (69.49) (69.49) (69.49)
S1 197.85$^{ }$
(143.81)
S2 -169.25$^{ }$
(142.74)
Observations 442.0 442.0 442.0 442.0 442.0
R$^2$ 0.4 0.4 0.4 0.4 0.4
Adj. R$^2$ 0.39 0.39 0.39 0.39 0.39
Residual Std. Error 59.98 59.98 59.98 59.98 59.98
F Statistic 72.91$^{***}$ 48.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$
Note:***p<0.01; **p<0.05; *p<0.1
[10]:
ex_latex = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="latex",
    left_decimals=4,
    alignment_warning=False,
    siunitx_warning=False,
)
Latex(ex_latex)
[10]:
\begin{tabular}{lS[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]} \toprule {} & {(1)} & {(2)} & {(3)} & {(4)} & {(5)} \\ \midrule const & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ \\ & (2.85) & (2.85) & (2.85) & (2.85) & (2.85) \\ Age & 37.24$^{ }$ & 24.7$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ \\ & (64.12) & (65.41) & (64.12) & (64.12) & (64.12) \\ Sex & -106.58$^{* }$ & -82.86$^{ }$ & -106.58$^{* }$ & -106.58$^{* }$ & -106.58$^{* }$ \\ & (62.13) & (64.85) & (62.13) & (62.13) & (62.13) \\ BMI & 787.18$^{*** }$ & 789.74$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ \\ & (65.42) & (66.89) & (65.42) & (65.42) & (65.42) \\ ABP & 416.67$^{*** }$ & 397.58$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ \\ & (69.49) & (70.87) & (69.49) & (69.49) & (69.49) \\ S1 & & 197.85$^{ }$ & & & \\ & & (143.81) & & & \\ S2 & & -169.25$^{ }$ & & & \\ & & (142.74) & & & \\ \midrule Observations & 442.0 & 442.0 & 442.0 & 442.0 & 442.0 \\ R$^2$ & 0.4 & 0.4 & 0.4 & 0.4 & 0.4 \\ Adj. R$^2$ & 0.39 & 0.39 & 0.39 & 0.39 & 0.39 \\ Residual Std. Error & 59.98 & 59.98 & 59.98 & 59.98 & 59.98 \\ F Statistic & 72.91$^{***}$ & 48.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ \\ \midrule \textit{Note:} & \multicolumn{5}{r}{$^{***}$p$<$0.01;$^{**}$p$<$0.05;$^{*}$p$<$0.1} \\ \bottomrule \end{tabular}

Basic table, with title

[11]:
ex_html = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="html",
    render_options={"caption": "This is a caption"},
)
HTML(ex_html)
[11]:
This is a caption
(1) (2) (3) (4) (5)
const 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$
(2.85) (2.85) (2.85) (2.85) (2.85)
Age 37.24$^{ }$ 24.7$^{ }$ 37.24$^{ }$ 37.24$^{ }$ 37.24$^{ }$
(64.12) (65.41) (64.12) (64.12) (64.12)
Sex -106.58$^{* }$ -82.86$^{ }$ -106.58$^{* }$ -106.58$^{* }$ -106.58$^{* }$
(62.13) (64.85) (62.13) (62.13) (62.13)
BMI 787.18$^{*** }$ 789.74$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$
(65.42) (66.89) (65.42) (65.42) (65.42)
ABP 416.67$^{*** }$ 397.58$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$
(69.49) (70.87) (69.49) (69.49) (69.49)
S1 197.85$^{ }$
(143.81)
S2 -169.25$^{ }$
(142.74)
Observations 442.0 442.0 442.0 442.0 442.0
R$^2$ 0.4 0.4 0.4 0.4 0.4
Adj. R$^2$ 0.39 0.39 0.39 0.39 0.39
Residual Std. Error 59.98 59.98 59.98 59.98 59.98
F Statistic 72.91$^{***}$ 48.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$
Note:***p<0.01; **p<0.05; *p<0.1
[12]:
ex_tex = et.estimation_table(
    [est, est2, est3, est4, est5],
    left_decimals=4,
    return_type="latex",
    render_options={"caption": "This is a caption"},
    alignment_warning=False,
    siunitx_warning=False,
)
Latex(ex_tex)
[12]:
\begin{table} \centering \caption{This is a caption} \begin{tabular}{lS[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]} \toprule {} & {(1)} & {(2)} & {(3)} & {(4)} & {(5)} \\ \midrule const & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ \\ & (2.85) & (2.85) & (2.85) & (2.85) & (2.85) \\ Age & 37.24$^{ }$ & 24.7$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ \\ & (64.12) & (65.41) & (64.12) & (64.12) & (64.12) \\ Sex & -106.58$^{* }$ & -82.86$^{ }$ & -106.58$^{* }$ & -106.58$^{* }$ & -106.58$^{* }$ \\ & (62.13) & (64.85) & (62.13) & (62.13) & (62.13) \\ BMI & 787.18$^{*** }$ & 789.74$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ \\ & (65.42) & (66.89) & (65.42) & (65.42) & (65.42) \\ ABP & 416.67$^{*** }$ & 397.58$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ \\ & (69.49) & (70.87) & (69.49) & (69.49) & (69.49) \\ S1 & & 197.85$^{ }$ & & & \\ & & (143.81) & & & \\ S2 & & -169.25$^{ }$ & & & \\ & & (142.74) & & & \\ \midrule Observations & 442.0 & 442.0 & 442.0 & 442.0 & 442.0 \\ R$^2$ & 0.4 & 0.4 & 0.4 & 0.4 & 0.4 \\ Adj. R$^2$ & 0.39 & 0.39 & 0.39 & 0.39 & 0.39 \\ Residual Std. Error & 59.98 & 59.98 & 59.98 & 59.98 & 59.98 \\ F Statistic & 72.91$^{***}$ & 48.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ \\ \midrule \textit{Note:} & \multicolumn{5}{r}{$^{***}$p$<$0.01;$^{**}$p$<$0.05;$^{*}$p$<$0.1} \\ \bottomrule \end{tabular} \end{table}

Column names

[13]:
ex_html = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="html",
    render_options={"caption": "This is a caption"},
    custom_col_names=list("abcde"),
)
HTML(ex_html)
[13]:
This is a caption
a b c d e
const 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$
(2.85) (2.85) (2.85) (2.85) (2.85)
Age 37.24$^{ }$ 24.7$^{ }$ 37.24$^{ }$ 37.24$^{ }$ 37.24$^{ }$
(64.12) (65.41) (64.12) (64.12) (64.12)
Sex -106.58$^{* }$ -82.86$^{ }$ -106.58$^{* }$ -106.58$^{* }$ -106.58$^{* }$
(62.13) (64.85) (62.13) (62.13) (62.13)
BMI 787.18$^{*** }$ 789.74$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$
(65.42) (66.89) (65.42) (65.42) (65.42)
ABP 416.67$^{*** }$ 397.58$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$
(69.49) (70.87) (69.49) (69.49) (69.49)
S1 197.85$^{ }$
(143.81)
S2 -169.25$^{ }$
(142.74)
Observations 442.0 442.0 442.0 442.0 442.0
R$^2$ 0.4 0.4 0.4 0.4 0.4
Adj. R$^2$ 0.39 0.39 0.39 0.39 0.39
Residual Std. Error 59.98 59.98 59.98 59.98 59.98
F Statistic 72.91$^{***}$ 48.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$
Note:***p<0.01; **p<0.05; *p<0.1
[14]:
ex_tex = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="latex",
    render_options={"caption": "This is a caption"},
    left_decimals=4,
    custom_col_names=list("abcde"),
    alignment_warning=False,
    siunitx_warning=False,
)
Latex(ex_tex)
[14]:
\begin{table} \centering \caption{This is a caption} \begin{tabular}{lS[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]} \toprule {} & {a} & {b} & {c} & {d} & {e} \\ \midrule const & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ \\ & (2.85) & (2.85) & (2.85) & (2.85) & (2.85) \\ Age & 37.24$^{ }$ & 24.7$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ \\ & (64.12) & (65.41) & (64.12) & (64.12) & (64.12) \\ Sex & -106.58$^{* }$ & -82.86$^{ }$ & -106.58$^{* }$ & -106.58$^{* }$ & -106.58$^{* }$ \\ & (62.13) & (64.85) & (62.13) & (62.13) & (62.13) \\ BMI & 787.18$^{*** }$ & 789.74$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ \\ & (65.42) & (66.89) & (65.42) & (65.42) & (65.42) \\ ABP & 416.67$^{*** }$ & 397.58$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ \\ & (69.49) & (70.87) & (69.49) & (69.49) & (69.49) \\ S1 & & 197.85$^{ }$ & & & \\ & & (143.81) & & & \\ S2 & & -169.25$^{ }$ & & & \\ & & (142.74) & & & \\ \midrule Observations & 442.0 & 442.0 & 442.0 & 442.0 & 442.0 \\ R$^2$ & 0.4 & 0.4 & 0.4 & 0.4 & 0.4 \\ Adj. R$^2$ & 0.39 & 0.39 & 0.39 & 0.39 & 0.39 \\ Residual Std. Error & 59.98 & 59.98 & 59.98 & 59.98 & 59.98 \\ F Statistic & 72.91$^{***}$ & 48.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ \\ \midrule \textit{Note:} & \multicolumn{5}{r}{$^{***}$p$<$0.01;$^{**}$p$<$0.05;$^{*}$p$<$0.1} \\ \bottomrule \end{tabular} \end{table}

Column names can be hidden by passing show_col_names=False:

[15]:
ex_html = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="html",
    render_options={"caption": "This is a caption"},
    show_col_names=False,
)
HTML(ex_html)
[15]:
This is a caption
const 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$
(2.85) (2.85) (2.85) (2.85) (2.85)
Age 37.24$^{ }$ 24.7$^{ }$ 37.24$^{ }$ 37.24$^{ }$ 37.24$^{ }$
(64.12) (65.41) (64.12) (64.12) (64.12)
Sex -106.58$^{* }$ -82.86$^{ }$ -106.58$^{* }$ -106.58$^{* }$ -106.58$^{* }$
(62.13) (64.85) (62.13) (62.13) (62.13)
BMI 787.18$^{*** }$ 789.74$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$
(65.42) (66.89) (65.42) (65.42) (65.42)
ABP 416.67$^{*** }$ 397.58$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$
(69.49) (70.87) (69.49) (69.49) (69.49)
S1 197.85$^{ }$
(143.81)
S2 -169.25$^{ }$
(142.74)
Observations 442.0 442.0 442.0 442.0 442.0
R$^2$ 0.4 0.4 0.4 0.4 0.4
Adj. R$^2$ 0.39 0.39 0.39 0.39 0.39
Residual Std. Error 59.98 59.98 59.98 59.98 59.98
F Statistic 72.91$^{***}$ 48.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$
Note:***p<0.01; **p<0.05; *p<0.1
[16]:
ex_tex = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="latex",
    render_options={"caption": "This is a caption"},
    left_decimals=4,
    show_col_names=False,
    alignment_warning=False,
    siunitx_warning=False,
)
Latex(ex_tex)
[16]:
\begin{table} \centering \caption{This is a caption} \begin{tabular}{lS[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]} \toprule {} \\ \midrule const & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ \\ & (2.85) & (2.85) & (2.85) & (2.85) & (2.85) \\ Age & 37.24$^{ }$ & 24.7$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ \\ & (64.12) & (65.41) & (64.12) & (64.12) & (64.12) \\ Sex & -106.58$^{* }$ & -82.86$^{ }$ & -106.58$^{* }$ & -106.58$^{* }$ & -106.58$^{* }$ \\ & (62.13) & (64.85) & (62.13) & (62.13) & (62.13) \\ BMI & 787.18$^{*** }$ & 789.74$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ \\ & (65.42) & (66.89) & (65.42) & (65.42) & (65.42) \\ ABP & 416.67$^{*** }$ & 397.58$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ \\ & (69.49) & (70.87) & (69.49) & (69.49) & (69.49) \\ S1 & & 197.85$^{ }$ & & & \\ & & (143.81) & & & \\ S2 & & -169.25$^{ }$ & & & \\ & & (142.74) & & & \\ \midrule Observations & 442.0 & 442.0 & 442.0 & 442.0 & 442.0 \\ R$^2$ & 0.4 & 0.4 & 0.4 & 0.4 & 0.4 \\ Adj. R$^2$ & 0.39 & 0.39 & 0.39 & 0.39 & 0.39 \\ Residual Std. Error & 59.98 & 59.98 & 59.98 & 59.98 & 59.98 \\ F Statistic & 72.91$^{***}$ & 48.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ \\ \midrule \textit{Note:} & \multicolumn{5}{r}{$^{***}$p$<$0.01;$^{**}$p$<$0.05;$^{*}$p$<$0.1} \\ \bottomrule \end{tabular} \end{table}

Model names

[17]:
custom_mod_names = {"M a": [0], "M b-d": [1, 2, 3], "M e": [4]}
[18]:
ex_html = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="html",
    render_options={"caption": "This is a caption"},
    custom_model_names=custom_mod_names,
    custom_col_names=list("abcde"),
)
HTML(ex_html)
[18]:
This is a caption
M a M b-d M e
a b c d e
const 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$
(2.85) (2.85) (2.85) (2.85) (2.85)
Age 37.24$^{ }$ 24.7$^{ }$ 37.24$^{ }$ 37.24$^{ }$ 37.24$^{ }$
(64.12) (65.41) (64.12) (64.12) (64.12)
Sex -106.58$^{* }$ -82.86$^{ }$ -106.58$^{* }$ -106.58$^{* }$ -106.58$^{* }$
(62.13) (64.85) (62.13) (62.13) (62.13)
BMI 787.18$^{*** }$ 789.74$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$
(65.42) (66.89) (65.42) (65.42) (65.42)
ABP 416.67$^{*** }$ 397.58$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$
(69.49) (70.87) (69.49) (69.49) (69.49)
S1 197.85$^{ }$
(143.81)
S2 -169.25$^{ }$
(142.74)
Observations 442.0 442.0 442.0 442.0 442.0
R$^2$ 0.4 0.4 0.4 0.4 0.4
Adj. R$^2$ 0.39 0.39 0.39 0.39 0.39
Residual Std. Error 59.98 59.98 59.98 59.98 59.98
F Statistic 72.91$^{***}$ 48.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$
Note:***p<0.01; **p<0.05; *p<0.1
[19]:
ex_tex = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="latex",
    render_options={"caption": "This is a caption"},
    left_decimals=4,
    custom_model_names=custom_mod_names,
    custom_col_names=list("abcde"),
    alignment_warning=False,
    siunitx_warning=False,
)
Latex(ex_tex)
[19]:
\begin{table} \centering \caption{This is a caption} \begin{tabular}{lS[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]} \toprule {} & {M a} & \multicolumn{3}{c}{{M b-d}} & {M e} \\ \cmidrule(lr){2-2} \cmidrule(lr){3-5} \cmidrule(lr){6-6} {} & {a} & {b} & {c} & {d} & {e} \\ \midrule const & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ \\ & (2.85) & (2.85) & (2.85) & (2.85) & (2.85) \\ Age & 37.24$^{ }$ & 24.7$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ \\ & (64.12) & (65.41) & (64.12) & (64.12) & (64.12) \\ Sex & -106.58$^{* }$ & -82.86$^{ }$ & -106.58$^{* }$ & -106.58$^{* }$ & -106.58$^{* }$ \\ & (62.13) & (64.85) & (62.13) & (62.13) & (62.13) \\ BMI & 787.18$^{*** }$ & 789.74$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ \\ & (65.42) & (66.89) & (65.42) & (65.42) & (65.42) \\ ABP & 416.67$^{*** }$ & 397.58$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ \\ & (69.49) & (70.87) & (69.49) & (69.49) & (69.49) \\ S1 & & 197.85$^{ }$ & & & \\ & & (143.81) & & & \\ S2 & & -169.25$^{ }$ & & & \\ & & (142.74) & & & \\ \midrule Observations & 442.0 & 442.0 & 442.0 & 442.0 & 442.0 \\ R$^2$ & 0.4 & 0.4 & 0.4 & 0.4 & 0.4 \\ Adj. R$^2$ & 0.39 & 0.39 & 0.39 & 0.39 & 0.39 \\ Residual Std. Error & 59.98 & 59.98 & 59.98 & 59.98 & 59.98 \\ F Statistic & 72.91$^{***}$ & 48.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ \\ \midrule \textit{Note:} & \multicolumn{5}{r}{$^{***}$p$<$0.01;$^{**}$p$<$0.05;$^{*}$p$<$0.1} \\ \bottomrule \end{tabular} \end{table}

Index name

By default, the index name is “index”:

[20]:
ex_html = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="html",
    render_options={"caption": "This is a caption", "index_names": True},
    custom_model_names=custom_mod_names,
)
HTML(ex_html)
[20]:
This is a caption
M a M b-d M e
(1) (2) (3) (4) (5)
index
const 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$
(2.85) (2.85) (2.85) (2.85) (2.85)
Age 37.24$^{ }$ 24.7$^{ }$ 37.24$^{ }$ 37.24$^{ }$ 37.24$^{ }$
(64.12) (65.41) (64.12) (64.12) (64.12)
Sex -106.58$^{* }$ -82.86$^{ }$ -106.58$^{* }$ -106.58$^{* }$ -106.58$^{* }$
(62.13) (64.85) (62.13) (62.13) (62.13)
BMI 787.18$^{*** }$ 789.74$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$
(65.42) (66.89) (65.42) (65.42) (65.42)
ABP 416.67$^{*** }$ 397.58$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$
(69.49) (70.87) (69.49) (69.49) (69.49)
S1 197.85$^{ }$
(143.81)
S2 -169.25$^{ }$
(142.74)
Observations 442.0 442.0 442.0 442.0 442.0
R$^2$ 0.4 0.4 0.4 0.4 0.4
Adj. R$^2$ 0.39 0.39 0.39 0.39 0.39
Residual Std. Error 59.98 59.98 59.98 59.98 59.98
F Statistic 72.91$^{***}$ 48.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$
Note:***p<0.01; **p<0.05; *p<0.1
[21]:
ex_tex = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="latex",
    render_options={"caption": "This is a caption", "index_names": True},
    left_decimals=4,
    custom_model_names=custom_mod_names,
    alignment_warning=False,
    siunitx_warning=False,
)
Latex(ex_tex)
[21]:
\begin{table} \centering \caption{This is a caption} \begin{tabular}{lS[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]} \toprule {} & {M a} & \multicolumn{3}{c}{{M b-d}} & {M e} \\ \cmidrule(lr){2-2} \cmidrule(lr){3-5} \cmidrule(lr){6-6} {} & {(1)} & {(2)} & {(3)} & {(4)} & {(5)} \\ index & & & & & \\ \midrule const & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ \\ & (2.85) & (2.85) & (2.85) & (2.85) & (2.85) \\ Age & 37.24$^{ }$ & 24.7$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ \\ & (64.12) & (65.41) & (64.12) & (64.12) & (64.12) \\ Sex & -106.58$^{* }$ & -82.86$^{ }$ & -106.58$^{* }$ & -106.58$^{* }$ & -106.58$^{* }$ \\ & (62.13) & (64.85) & (62.13) & (62.13) & (62.13) \\ BMI & 787.18$^{*** }$ & 789.74$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ \\ & (65.42) & (66.89) & (65.42) & (65.42) & (65.42) \\ ABP & 416.67$^{*** }$ & 397.58$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ \\ & (69.49) & (70.87) & (69.49) & (69.49) & (69.49) \\ S1 & & 197.85$^{ }$ & & & \\ & & (143.81) & & & \\ S2 & & -169.25$^{ }$ & & & \\ & & (142.74) & & & \\ \midrule Observations & 442.0 & 442.0 & 442.0 & 442.0 & 442.0 \\ R$^2$ & 0.4 & 0.4 & 0.4 & 0.4 & 0.4 \\ Adj. R$^2$ & 0.39 & 0.39 & 0.39 & 0.39 & 0.39 \\ Residual Std. Error & 59.98 & 59.98 & 59.98 & 59.98 & 59.98 \\ F Statistic & 72.91$^{***}$ & 48.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ \\ \midrule \textit{Note:} & \multicolumn{5}{r}{$^{***}$p$<$0.01;$^{**}$p$<$0.05;$^{*}$p$<$0.1} \\ \bottomrule \end{tabular} \end{table}

This can be customized by passing a different index name to custom_index_names:

[22]:
ex_html = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="html",
    render_options={
        "caption": "This is a caption",
    },
    custom_index_names=["Variables"],
    custom_model_names=custom_mod_names,
)
HTML(ex_html)
[22]:
This is a caption
M a M b-d M e
(1) (2) (3) (4) (5)
Variables
const 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$
(2.85) (2.85) (2.85) (2.85) (2.85)
Age 37.24$^{ }$ 24.7$^{ }$ 37.24$^{ }$ 37.24$^{ }$ 37.24$^{ }$
(64.12) (65.41) (64.12) (64.12) (64.12)
Sex -106.58$^{* }$ -82.86$^{ }$ -106.58$^{* }$ -106.58$^{* }$ -106.58$^{* }$
(62.13) (64.85) (62.13) (62.13) (62.13)
BMI 787.18$^{*** }$ 789.74$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$
(65.42) (66.89) (65.42) (65.42) (65.42)
ABP 416.67$^{*** }$ 397.58$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$
(69.49) (70.87) (69.49) (69.49) (69.49)
S1 197.85$^{ }$
(143.81)
S2 -169.25$^{ }$
(142.74)
Observations 442.0 442.0 442.0 442.0 442.0
R$^2$ 0.4 0.4 0.4 0.4 0.4
Adj. R$^2$ 0.39 0.39 0.39 0.39 0.39
Residual Std. Error 59.98 59.98 59.98 59.98 59.98
F Statistic 72.91$^{***}$ 48.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$
Note:***p<0.01; **p<0.05; *p<0.1
[23]:
ex_tex = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="latex",
    render_options={
        "caption": "This is a caption",
    },
    custom_index_names=["Variables"],
    left_decimals=4,
    custom_model_names=custom_mod_names,
    alignment_warning=False,
    siunitx_warning=False,
)
Latex(ex_tex)
[23]:
\begin{table} \centering \caption{This is a caption} \begin{tabular}{lS[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]} \toprule {} & {M a} & \multicolumn{3}{c}{{M b-d}} & {M e} \\ \cmidrule(lr){2-2} \cmidrule(lr){3-5} \cmidrule(lr){6-6} {} & {(1)} & {(2)} & {(3)} & {(4)} & {(5)} \\ Variables & & & & & \\ \midrule const & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ \\ & (2.85) & (2.85) & (2.85) & (2.85) & (2.85) \\ Age & 37.24$^{ }$ & 24.7$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ \\ & (64.12) & (65.41) & (64.12) & (64.12) & (64.12) \\ Sex & -106.58$^{* }$ & -82.86$^{ }$ & -106.58$^{* }$ & -106.58$^{* }$ & -106.58$^{* }$ \\ & (62.13) & (64.85) & (62.13) & (62.13) & (62.13) \\ BMI & 787.18$^{*** }$ & 789.74$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ \\ & (65.42) & (66.89) & (65.42) & (65.42) & (65.42) \\ ABP & 416.67$^{*** }$ & 397.58$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ \\ & (69.49) & (70.87) & (69.49) & (69.49) & (69.49) \\ S1 & & 197.85$^{ }$ & & & \\ & & (143.81) & & & \\ S2 & & -169.25$^{ }$ & & & \\ & & (142.74) & & & \\ \midrule Observations & 442.0 & 442.0 & 442.0 & 442.0 & 442.0 \\ R$^2$ & 0.4 & 0.4 & 0.4 & 0.4 & 0.4 \\ Adj. R$^2$ & 0.39 & 0.39 & 0.39 & 0.39 & 0.39 \\ Residual Std. Error & 59.98 & 59.98 & 59.98 & 59.98 & 59.98 \\ F Statistic & 72.91$^{***}$ & 48.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ \\ \midrule \textit{Note:} & \multicolumn{5}{r}{$^{***}$p$<$0.01;$^{**}$p$<$0.05;$^{*}$p$<$0.1} \\ \bottomrule \end{tabular} \end{table}

Parameter names

Custom parameter names can be specified by passing a dictionary to custom_param_names:

[24]:
cust_par_names = {"const": "Intercept", "Sex": "Gender"}
[25]:
ex_html = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="html",
    render_options={
        "caption": "This is a caption",
    },
    custom_index_names=["Variables"],
    custom_model_names=custom_mod_names,
    custom_param_names=cust_par_names,
)
HTML(ex_html)
[25]:
This is a caption
M a M b-d M e
(1) (2) (3) (4) (5)
Variables
Intercept 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$
(2.85) (2.85) (2.85) (2.85) (2.85)
Age 37.24$^{ }$ 24.7$^{ }$ 37.24$^{ }$ 37.24$^{ }$ 37.24$^{ }$
(64.12) (65.41) (64.12) (64.12) (64.12)
Gender -106.58$^{* }$ -82.86$^{ }$ -106.58$^{* }$ -106.58$^{* }$ -106.58$^{* }$
(62.13) (64.85) (62.13) (62.13) (62.13)
BMI 787.18$^{*** }$ 789.74$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$
(65.42) (66.89) (65.42) (65.42) (65.42)
ABP 416.67$^{*** }$ 397.58$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$
(69.49) (70.87) (69.49) (69.49) (69.49)
S1 197.85$^{ }$
(143.81)
S2 -169.25$^{ }$
(142.74)
Observations 442.0 442.0 442.0 442.0 442.0
R$^2$ 0.4 0.4 0.4 0.4 0.4
Adj. R$^2$ 0.39 0.39 0.39 0.39 0.39
Residual Std. Error 59.98 59.98 59.98 59.98 59.98
F Statistic 72.91$^{***}$ 48.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$
Note:***p<0.01; **p<0.05; *p<0.1
[26]:
ex_tex = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="latex",
    render_options={
        "caption": "This is a caption",
    },
    custom_index_names=["Variables"],
    left_decimals=4,
    custom_model_names=custom_mod_names,
    custom_param_names=cust_par_names,
    alignment_warning=False,
    siunitx_warning=False,
)
Latex(ex_tex)
[26]:
\begin{table} \centering \caption{This is a caption} \begin{tabular}{lS[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]} \toprule & {M a} & \multicolumn{3}{c}{{M b-d}} & {M e} \\ \cmidrule(lr){2-2} \cmidrule(lr){3-5} \cmidrule(lr){6-6} & {(1)} & {(2)} & {(3)} & {(4)} & {(5)} \\ Variables & & & & & \\ \midrule Intercept & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ \\ & (2.85) & (2.85) & (2.85) & (2.85) & (2.85) \\ Age & 37.24$^{ }$ & 24.7$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ \\ & (64.12) & (65.41) & (64.12) & (64.12) & (64.12) \\ Gender & -106.58$^{* }$ & -82.86$^{ }$ & -106.58$^{* }$ & -106.58$^{* }$ & -106.58$^{* }$ \\ & (62.13) & (64.85) & (62.13) & (62.13) & (62.13) \\ BMI & 787.18$^{*** }$ & 789.74$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ \\ & (65.42) & (66.89) & (65.42) & (65.42) & (65.42) \\ ABP & 416.67$^{*** }$ & 397.58$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ \\ & (69.49) & (70.87) & (69.49) & (69.49) & (69.49) \\ S1 & & 197.85$^{ }$ & & & \\ & & (143.81) & & & \\ S2 & & -169.25$^{ }$ & & & \\ & & (142.74) & & & \\ \midrule Observations & 442.0 & 442.0 & 442.0 & 442.0 & 442.0 \\ R$^2$ & 0.4 & 0.4 & 0.4 & 0.4 & 0.4 \\ Adj. R$^2$ & 0.39 & 0.39 & 0.39 & 0.39 & 0.39 \\ Residual Std. Error & 59.98 & 59.98 & 59.98 & 59.98 & 59.98 \\ F Statistic & 72.91$^{***}$ & 48.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ \\ \midrule \textit{Note:} & \multicolumn{5}{r}{$^{***}$p$<$0.01;$^{**}$p$<$0.05;$^{*}$p$<$0.1} \\ \bottomrule \end{tabular} \end{table}

Advanced

Confidence intervals

[27]:
ex_html = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="html",
    render_options={
        "caption": "This is a caption",
    },
    custom_index_names=["Variables"],
    custom_model_names=custom_mod_names,
    custom_param_names=cust_par_names,
    confidence_intervals=True,
)
HTML(ex_html)
[27]:
This is a caption
M a M b-d M e
(1) (2) (3) (4) (5)
Variables
Intercept 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$
(146.53 ; 157.74) (146.53 ; 157.74) (146.53 ; 157.74) (146.53 ; 157.74) (146.53 ; 157.74)
Age 37.24$^{ }$ 24.7$^{ }$ 37.24$^{ }$ 37.24$^{ }$ 37.24$^{ }$
(-88.78 ; 163.26) (-103.86 ; 153.26) (-88.78 ; 163.26) (-88.78 ; 163.26) (-88.78 ; 163.26)
Gender -106.58$^{* }$ -82.86$^{ }$ -106.58$^{* }$ -106.58$^{* }$ -106.58$^{* }$
(-228.68 ; 15.52) (-210.32 ; 44.6) (-228.68 ; 15.52) (-228.68 ; 15.52) (-228.68 ; 15.52)
BMI 787.18$^{*** }$ 789.74$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$
(658.59 ; 915.76) (658.28 ; 921.2) (658.59 ; 915.76) (658.59 ; 915.76) (658.59 ; 915.76)
ABP 416.67$^{*** }$ 397.58$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$
(280.09 ; 553.26) (258.29 ; 536.87) (280.09 ; 553.26) (280.09 ; 553.26) (280.09 ; 553.26)
S1 197.85$^{ }$
(-84.8 ; 480.51)
S2 -169.25$^{ }$
(-449.8 ; 111.3)
Observations 442.0 442.0 442.0 442.0 442.0
R$^2$ 0.4 0.4 0.4 0.4 0.4
Adj. R$^2$ 0.39 0.39 0.39 0.39 0.39
Residual Std. Error 59.98 59.98 59.98 59.98 59.98
F Statistic 72.91$^{***}$ 48.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$
Note:***p<0.01; **p<0.05; *p<0.1
[28]:
ex_tex = et.estimation_table(
    [est, est2, est3, est4],
    return_type="latex",
    render_options={
        "caption": "This is a caption",
    },
    custom_index_names=["Variables"],
    left_decimals=4,
    custom_model_names=None,
    custom_param_names=cust_par_names,
    alignment_warning=False,
    siunitx_warning=False,
    confidence_intervals=True,
)
Latex(ex_tex)
[28]:
\begin{table} \centering \caption{This is a caption} \begin{tabular}{lS[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]} \toprule & {(1)} & {(2)} & {(3)} & {(4)} \\ Variables & & & & \\ \midrule Intercept & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ \\ & {(146.53\,;\,157.74)} & {(146.53\,;\,157.74)} & {(146.53\,;\,157.74)} & {(146.53\,;\,157.74)} \\ Age & 37.24$^{ }$ & 24.7$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ \\ & {(-88.78\,;\,163.26)} & {(-103.86\,;\,153.26)} & {(-88.78\,;\,163.26)} & {(-88.78\,;\,163.26)} \\ Gender & -106.58$^{* }$ & -82.86$^{ }$ & -106.58$^{* }$ & -106.58$^{* }$ \\ & {(-228.68\,;\,15.52)} & {(-210.32\,;\,44.6)} & {(-228.68\,;\,15.52)} & {(-228.68\,;\,15.52)} \\ BMI & 787.18$^{*** }$ & 789.74$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ \\ & {(658.59\,;\,915.76)} & {(658.28\,;\,921.2)} & {(658.59\,;\,915.76)} & {(658.59\,;\,915.76)} \\ ABP & 416.67$^{*** }$ & 397.58$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ \\ & {(280.09\,;\,553.26)} & {(258.29\,;\,536.87)} & {(280.09\,;\,553.26)} & {(280.09\,;\,553.26)} \\ S1 & & 197.85$^{ }$ & & \\ & & {(-84.8\,;\,480.51)} & & \\ S2 & & -169.25$^{ }$ & & \\ & & {(-449.8\,;\,111.3)} & & \\ \midrule Observations & 442.0 & 442.0 & 442.0 & 442.0 \\ R$^2$ & 0.4 & 0.4 & 0.4 & 0.4 \\ Adj. R$^2$ & 0.39 & 0.39 & 0.39 & 0.39 \\ Residual Std. Error & 59.98 & 59.98 & 59.98 & 59.98 \\ F Statistic & 72.91$^{***}$ & 48.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ \\ \midrule \textit{Note:} & \multicolumn{4}{r}{$^{***}$p$<$0.01;$^{**}$p$<$0.05;$^{*}$p$<$0.1} \\ \bottomrule \end{tabular} \end{table}

Passing confidence_intervals=False prints standard errors. To hide both standard errors and confidence intervals you need to pass show_inference=False:

[29]:
ex_html = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="html",
    render_options={"caption": "This is a caption"},
    custom_index_names=["Variables"],
    custom_model_names=custom_mod_names,
    custom_param_names=cust_par_names,
    show_inference=False,
)
HTML(ex_html)
[29]:
This is a caption
M a M b-d M e
(1) (2) (3) (4) (5)
Variables
Intercept 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$
Age 37.24$^{ }$ 24.7$^{ }$ 37.24$^{ }$ 37.24$^{ }$ 37.24$^{ }$
Gender -106.58$^{* }$ -82.86$^{ }$ -106.58$^{* }$ -106.58$^{* }$ -106.58$^{* }$
BMI 787.18$^{*** }$ 789.74$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$
ABP 416.67$^{*** }$ 397.58$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$
S1 197.85$^{ }$
S2 -169.25$^{ }$
Observations 442.0 442.0 442.0 442.0 442.0
R$^2$ 0.4 0.4 0.4 0.4 0.4
Adj. R$^2$ 0.39 0.39 0.39 0.39 0.39
Residual Std. Error 59.98 59.98 59.98 59.98 59.98
F Statistic 72.91$^{***}$ 48.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$
Note:***p<0.01; **p<0.05; *p<0.1
[30]:
ex_tex = et.estimation_table(
    [est, est2, est3, est4],
    return_type="latex",
    render_options={
        "caption": "This is a caption",
    },
    custom_index_names=["Variables"],
    left_decimals=4,
    custom_model_names=None,
    custom_param_names=cust_par_names,
    alignment_warning=False,
    siunitx_warning=False,
    show_inference=False,
)
Latex(ex_tex)
[30]:
\begin{table} \centering \caption{This is a caption} \begin{tabular}{lS[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]} \toprule & {(1)} & {(2)} & {(3)} & {(4)} \\ Variables & & & & \\ \midrule Intercept & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ \\ Age & 37.24$^{ }$ & 24.7$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ \\ Gender & -106.58$^{* }$ & -82.86$^{ }$ & -106.58$^{* }$ & -106.58$^{* }$ \\ BMI & 787.18$^{*** }$ & 789.74$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ \\ ABP & 416.67$^{*** }$ & 397.58$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ \\ S1 & & 197.85$^{ }$ & & \\ S2 & & -169.25$^{ }$ & & \\ \midrule Observations & 442.0 & 442.0 & 442.0 & 442.0 \\ R$^2$ & 0.4 & 0.4 & 0.4 & 0.4 \\ Adj. R$^2$ & 0.39 & 0.39 & 0.39 & 0.39 \\ Residual Std. Error & 59.98 & 59.98 & 59.98 & 59.98 \\ F Statistic & 72.91$^{***}$ & 48.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ \\ \midrule \textit{Note:} & \multicolumn{4}{r}{$^{***}$p$<$0.01;$^{**}$p$<$0.05;$^{*}$p$<$0.1} \\ \bottomrule \end{tabular} \end{table}

Custom notes

[33]:
ex_html = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="html",
    render_options={"caption": "This is a caption"},
    custom_param_names=cust_par_names,
    custom_notes=[
        "This is the first note of some length",
        "This is the second note probably of larger length",
    ],
)
HTML(ex_html)
[33]:
This is a caption
(1) (2) (3) (4) (5)
Intercept 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$
(2.85) (2.85) (2.85) (2.85) (2.85)
Age 37.24$^{ }$ 24.7$^{ }$ 37.24$^{ }$ 37.24$^{ }$ 37.24$^{ }$
(64.12) (65.41) (64.12) (64.12) (64.12)
Gender -106.58$^{* }$ -82.86$^{ }$ -106.58$^{* }$ -106.58$^{* }$ -106.58$^{* }$
(62.13) (64.85) (62.13) (62.13) (62.13)
BMI 787.18$^{*** }$ 789.74$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$
(65.42) (66.89) (65.42) (65.42) (65.42)
ABP 416.67$^{*** }$ 397.58$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$
(69.49) (70.87) (69.49) (69.49) (69.49)
S1 197.85$^{ }$
(143.81)
S2 -169.25$^{ }$
(142.74)
Observations 442.0 442.0 442.0 442.0 442.0
R$^2$ 0.4 0.4 0.4 0.4 0.4
Adj. R$^2$ 0.39 0.39 0.39 0.39 0.39
Residual Std. Error 59.98 59.98 59.98 59.98 59.98
F Statistic 72.91$^{***}$ 48.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$ 72.91$^{***}$
Note:***p<0.01; **p<0.05; *p<0.1
This is the first note of some length
This is the second note probably of larger length
[34]:
ex_tex = et.estimation_table(
    [est, est2, est3, est4],
    return_type="latex",
    render_options={
        "caption": "This is a caption",
    },
    left_decimals=4,
    custom_model_names=None,
    custom_param_names=cust_par_names,
    alignment_warning=False,
    siunitx_warning=False,
    custom_notes=[
        "This is the first note of some length",
        "This is the second note probably of larger length",
    ],
)
Latex(ex_tex)
[34]:
\begin{table} \centering \caption{This is a caption} \begin{tabular}{lS[table-format =4.2]S[table-format =4.2]S[table-format =4.2]S[table-format =4.2]} \toprule & {(1)} & {(2)} & {(3)} & {(4)} \\ \midrule Intercept & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ & 152.13$^{*** }$ \\ & (2.85) & (2.85) & (2.85) & (2.85) \\ Age & 37.24$^{ }$ & 24.7$^{ }$ & 37.24$^{ }$ & 37.24$^{ }$ \\ & (64.12) & (65.41) & (64.12) & (64.12) \\ Gender & -106.58$^{* }$ & -82.86$^{ }$ & -106.58$^{* }$ & -106.58$^{* }$ \\ & (62.13) & (64.85) & (62.13) & (62.13) \\ BMI & 787.18$^{*** }$ & 789.74$^{*** }$ & 787.18$^{*** }$ & 787.18$^{*** }$ \\ & (65.42) & (66.89) & (65.42) & (65.42) \\ ABP & 416.67$^{*** }$ & 397.58$^{*** }$ & 416.67$^{*** }$ & 416.67$^{*** }$ \\ & (69.49) & (70.87) & (69.49) & (69.49) \\ S1 & & 197.85$^{ }$ & & \\ & & (143.81) & & \\ S2 & & -169.25$^{ }$ & & \\ & & (142.74) & & \\ \midrule Observations & 442.0 & 442.0 & 442.0 & 442.0 \\ R$^2$ & 0.4 & 0.4 & 0.4 & 0.4 \\ Adj. R$^2$ & 0.39 & 0.39 & 0.39 & 0.39 \\ Residual Std. Error & 59.98 & 59.98 & 59.98 & 59.98 \\ F Statistic & 72.91$^{***}$ & 48.91$^{***}$ & 72.91$^{***}$ & 72.91$^{***}$ \\ \midrule \textit{Note:} & \multicolumn{4}{r}{$^{***}$p$<$0.01;$^{**}$p$<$0.05;$^{*}$p$<$0.1} \\ &\multicolumn{4}{r}\textit{This is the first note of some length}\\ &\multicolumn{4}{r}\textit{This is the second note probably of larger length}\\ \bottomrule \end{tabular} \end{table}

Custom names for summary statistics

[35]:
ex_html = et.estimation_table(
    [est, est2, est3, est4, est5],
    return_type="html",
    render_options={"caption": "This is a caption"},
    custom_param_names=cust_par_names,
    custom_notes=[
        "This is the first note of some length",
        "This is the second note probably of larger length",
    ],
    stats_dict={"R$^2$": "rsquared", "N. Obs": "n_obs"},
)
HTML(ex_html)
[35]:
This is a caption
(1) (2) (3) (4) (5)
Intercept 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$
(2.85) (2.85) (2.85) (2.85) (2.85)
Age 37.24$^{ }$ 24.7$^{ }$ 37.24$^{ }$ 37.24$^{ }$ 37.24$^{ }$
(64.12) (65.41) (64.12) (64.12) (64.12)
Gender -106.58$^{* }$ -82.86$^{ }$ -106.58$^{* }$ -106.58$^{* }$ -106.58$^{* }$
(62.13) (64.85) (62.13) (62.13) (62.13)
BMI 787.18$^{*** }$ 789.74$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$ 787.18$^{*** }$
(65.42) (66.89) (65.42) (65.42) (65.42)
ABP 416.67$^{*** }$ 397.58$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$ 416.67$^{*** }$
(69.49) (70.87) (69.49) (69.49) (69.49)
S1 197.85$^{ }$
(143.81)
S2 -169.25$^{ }$
(142.74)
R$^2$ 0.4 0.4 0.4 0.4 0.4
N. Obs 442.0 442.0 442.0 442.0 442.0
Note:***p<0.01; **p<0.05; *p<0.1
This is the first note of some length
This is the second note probably of larger length

MultiIndex

Set up

[36]:
# Convert `params` DataFrame to MultiIndex
df = et._extract_params_from_sm(est)
df.index = pd.MultiIndex.from_arrays(
    np.array([["Intercept", "Slope", "Slope", "Slope", "Slope"], df.index.values])
)
df
[36]:
value pvalue standard_error ci_lower ci_upper
Intercept const 152.133484 2.048808e-193 2.852749 146.526671 157.740298
Slope Age 37.241211 5.616557e-01 64.117433 -88.775663 163.258084
Sex -106.577520 8.695658e-02 62.125062 -228.678572 15.523532
BMI 787.179313 5.345260e-29 65.424126 658.594255 915.764371
ABP 416.673772 4.245663e-09 69.494666 280.088446 553.259097
[37]:
# Extract info and generate tuple of estimation results for `est1`
info = et._extract_info_from_sm(est)
est_mi = namedtuplee(params=df, info=info)
[38]:
# Repeat for `est2`
df = et._extract_params_from_sm(est2)
df.index = pd.MultiIndex.from_arrays(
    np.array(
        [
            ["Intercept", "Slope", "Slope", "Slope", "Slope", "Else", "Else"],
            df.index.values,
        ]
    )
)
info = et._extract_info_from_sm(est2)
est_mi2 = namedtuplee(params=df, info=info)

Basics

[39]:
ex_html = et.estimation_table(
    [est_mi, est_mi2],
    return_type="html",
    render_options={
        "caption": "This is a caption",
    },
    custom_param_names=cust_par_names,
    custom_notes=[
        "This is the first note of some length",
        "This is the second note probably of larger length",
    ],
)
HTML(ex_html)
[39]:
This is a caption
(1) (2)
Intercept Intercept 152.13$^{*** }$ 152.13$^{*** }$
(2.85) (2.85)
Slope Age 37.24$^{ }$ 24.7$^{ }$
(64.12) (65.41)
Gender -106.58$^{* }$ -82.86$^{ }$
(62.13) (64.85)
BMI 787.18$^{*** }$ 789.74$^{*** }$
(65.42) (66.89)
ABP 416.67$^{*** }$ 397.58$^{*** }$
(69.49) (70.87)
Else S1 197.85$^{ }$
(143.81)
S2 -169.25$^{ }$
(142.74)
Observations 442.0 442.0
R$^2$ 0.4 0.4
Adj. R$^2$ 0.39 0.39
Residual Std. Error 59.98 59.98
F Statistic 72.91$^{***}$ 48.91$^{***}$
Note:***p<0.01; **p<0.05; *p<0.1
This is the first note of some length
This is the second note probably of larger length
[40]:
ex_tex = et.estimation_table(
    [est_mi, est_mi2],
    return_type="latex",
    render_options={
        "caption": "This is a caption",
    },
    left_decimals=3,
    custom_model_names=None,
    custom_param_names=cust_par_names,
    alignment_warning=False,
    siunitx_warning=False,
    custom_notes=[
        "This is the first note of some length",
        "This is the second note probably of larger length",
    ],
)
Latex(ex_tex)
[40]:
\begin{table} \centering \caption{This is a caption} \begin{tabular}{llS[table-format =3.2]S[table-format =3.2]} \toprule & & {(1)} & {(2)} \\ \midrule Intercept & Intercept & 152.13$^{*** }$ & 152.13$^{*** }$ \\ & & (2.85) & (2.85) \\ Slope & Age & 37.24$^{ }$ & 24.7$^{ }$ \\ & & (64.12) & (65.41) \\ & Gender & -106.58$^{* }$ & -82.86$^{ }$ \\ & & (62.13) & (64.85) \\ & BMI & 787.18$^{*** }$ & 789.74$^{*** }$ \\ & & (65.42) & (66.89) \\ & ABP & 416.67$^{*** }$ & 397.58$^{*** }$ \\ & & (69.49) & (70.87) \\ Else & S1 & & 197.85$^{ }$ \\ & & & (143.81) \\ & S2 & & -169.25$^{ }$ \\ & & & (142.74) \\ \midrule Observations & {} & 442.0 & 442.0 \\ R$^2$ & {} & 0.4 & 0.4 \\ Adj. R$^2$ & {} & 0.39 & 0.39 \\ Residual Std. Error & {} & 59.98 & 59.98 \\ F Statistic & {} & 72.91$^{***}$ & 48.91$^{***}$ \\ \midrule \textit{Note:} & \multicolumn{3}{r}{$^{***}$p$<$0.01;$^{**}$p$<$0.05;$^{*}$p$<$0.1} \\ &&\multicolumn{2}{r}\textit{This is the first note of some length}\\ &&\multicolumn{2}{r}\textit{This is the second note probably of larger length}\\ \bottomrule \end{tabular} \end{table}

Parameter names

[41]:
ex_html = et.estimation_table(
    [est_mi, est_mi2],
    return_type="html",
    render_options={
        "caption": "This is a caption",
    },
    custom_notes=[
        "This is the first note of some length",
        "This is the second note probably of larger length",
    ],
    custom_param_names={"Age": "Maturity", "Else": "Additionally"},
)
HTML(ex_html)
[41]:
This is a caption
(1) (2)
Intercept const 152.13$^{*** }$ 152.13$^{*** }$
(2.85) (2.85)
Slope Maturity 37.24$^{ }$ 24.7$^{ }$
(64.12) (65.41)
Sex -106.58$^{* }$ -82.86$^{ }$
(62.13) (64.85)
BMI 787.18$^{*** }$ 789.74$^{*** }$
(65.42) (66.89)
ABP 416.67$^{*** }$ 397.58$^{*** }$
(69.49) (70.87)
Additionally S1 197.85$^{ }$
(143.81)
S2 -169.25$^{ }$
(142.74)
Observations 442.0 442.0
R$^2$ 0.4 0.4
Adj. R$^2$ 0.39 0.39
Residual Std. Error 59.98 59.98
F Statistic 72.91$^{***}$ 48.91$^{***}$
Note:***p<0.01; **p<0.05; *p<0.1
This is the first note of some length
This is the second note probably of larger length
[42]:
ex_tex = et.estimation_table(
    [est_mi, est_mi2],
    return_type="latex",
    render_options={
        "caption": "This is a caption",
    },
    left_decimals=3,
    custom_model_names=None,
    alignment_warning=False,
    siunitx_warning=False,
    custom_notes=[
        "This is the first note of some length",
        "This is the second note probably of larger length",
    ],
    custom_param_names={"Age": "Maturity", "Else": "Additionally"},
)
Latex(ex_tex)
[42]:
\begin{table} \centering \caption{This is a caption} \begin{tabular}{llS[table-format =3.2]S[table-format =3.2]} \toprule & & {(1)} & {(2)} \\ \midrule Intercept & const & 152.13$^{*** }$ & 152.13$^{*** }$ \\ & & (2.85) & (2.85) \\ Slope & Maturity & 37.24$^{ }$ & 24.7$^{ }$ \\ & & (64.12) & (65.41) \\ & Sex & -106.58$^{* }$ & -82.86$^{ }$ \\ & & (62.13) & (64.85) \\ & BMI & 787.18$^{*** }$ & 789.74$^{*** }$ \\ & & (65.42) & (66.89) \\ & ABP & 416.67$^{*** }$ & 397.58$^{*** }$ \\ & & (69.49) & (70.87) \\ Additionally & S1 & & 197.85$^{ }$ \\ & & & (143.81) \\ & S2 & & -169.25$^{ }$ \\ & & & (142.74) \\ \midrule Observations & {} & 442.0 & 442.0 \\ R$^2$ & {} & 0.4 & 0.4 \\ Adj. R$^2$ & {} & 0.39 & 0.39 \\ Residual Std. Error & {} & 59.98 & 59.98 \\ F Statistic & {} & 72.91$^{***}$ & 48.91$^{***}$ \\ \midrule \textit{Note:} & \multicolumn{3}{r}{$^{***}$p$<$0.01;$^{**}$p$<$0.05;$^{*}$p$<$0.1} \\ &&\multicolumn{2}{r}\textit{This is the first note of some length}\\ &&\multicolumn{2}{r}\textit{This is the second note probably of larger length}\\ \bottomrule \end{tabular} \end{table}

Index and model names

[43]:
stats_dict = {
    "Observations": "n_obs",
    "R$^2$": "rsquared",
    "Adj. R$^2$": "rsquared_adj",
    "Residual Std. Error": "resid_std_err",
    "F Statistic": "fvalue",
    "show_dof": True,
}
[44]:
ex_html = et.estimation_table(
    [est_mi, est_mi2, est_mi],
    return_type="html",
    render_options={
        "caption": "This is a caption",
    },
    custom_notes=[
        "This is the first note of some length",
        "This is the second note probably of larger length",
    ],
    custom_param_names={"Age": "Maturity", "Else": "Additionally"},
    custom_index_names=["Category", "Variable"],
    custom_model_names={"M1-2": [0, 1], "M3": [2]},
    stats_dict=stats_dict,
)
HTML(ex_html)
[44]:
This is a caption
M1-2 M3
(1) (2) (3)
Category Variable
Intercept const 152.13$^{*** }$ 152.13$^{*** }$ 152.13$^{*** }$
(2.85) (2.85) (2.85)
Slope Maturity 37.24$^{ }$ 24.7$^{ }$ 37.24$^{ }$
(64.12) (65.41) (64.12)
Sex -106.58$^{* }$ -82.86$^{ }$ -106.58$^{* }$
(62.13) (64.85) (62.13)
BMI 787.18$^{*** }$ 789.74$^{*** }$ 787.18$^{*** }$
(65.42) (66.89) (65.42)
ABP 416.67$^{*** }$ 397.58$^{*** }$ 416.67$^{*** }$
(69.49) (70.87) (69.49)
Additionally S1 197.85$^{ }$
(143.81)
S2 -169.25$^{ }$
(142.74)
Observations 442.0 442.0 442.0
R$^2$ 0.4 0.4 0.4
Adj. R$^2$ 0.39 0.39 0.39
Residual Std. Error 59.98(df=437.0) 59.98(df=435.0) 59.98(df=437.0)
F Statistic 72.91$^{***}$(df=4.0;437.0) 48.91$^{***}$(df=6.0;435.0) 72.91$^{***}$(df=4.0;437.0)
Note:***p<0.01; **p<0.05; *p<0.1
This is the first note of some length
This is the second note probably of larger length
[45]:
ex_tex = et.estimation_table(
    [est_mi, est_mi2],
    return_type="latex",
    render_options={
        "caption": "This is a caption",
    },
    left_decimals=4,
    alignment_warning=False,
    siunitx_warning=False,
    custom_notes=[
        "This is the first note of some length",
        "This is the second note probably of larger length",
    ],
    custom_param_names={"Age": "Maturity", "Else": "Additionally"},
    custom_index_names=["Category", "Variable"],
    custom_model_names={"M1": [0], "M2": [1]},
    stats_dict=stats_dict,
)
Latex(ex_tex)
[45]:
\begin{table} \centering \caption{This is a caption} \begin{tabular}{llS[table-format =4.2]S[table-format =4.2]} \toprule & & {M1} & {M2} \\ \cmidrule(lr){3-3} \cmidrule(lr){4-4} & & {(1)} & {(2)} \\ Category & Variable & & \\ \midrule Intercept & const & 152.13$^{*** }$ & 152.13$^{*** }$ \\ & & (2.85) & (2.85) \\ Slope & Maturity & 37.24$^{ }$ & 24.7$^{ }$ \\ & & (64.12) & (65.41) \\ & Sex & -106.58$^{* }$ & -82.86$^{ }$ \\ & & (62.13) & (64.85) \\ & BMI & 787.18$^{*** }$ & 789.74$^{*** }$ \\ & & (65.42) & (66.89) \\ & ABP & 416.67$^{*** }$ & 397.58$^{*** }$ \\ & & (69.49) & (70.87) \\ Additionally & S1 & & 197.85$^{ }$ \\ & & & (143.81) \\ & S2 & & -169.25$^{ }$ \\ & & & (142.74) \\ \midrule Observations & {} & 442.0 & 442.0 \\ R$^2$ & {} & 0.4 & 0.4 \\ Adj. R$^2$ & {} & 0.39 & 0.39 \\ Residual Std. Error & {} & {59.98(df=437.0)} & {59.98(df=435.0)} \\ F Statistic & {} & {72.91$^{***}$(df=4.0;437.0)} & {48.91$^{***}$(df=6.0;435.0)} \\ \midrule \textit{Note:} & \multicolumn{3}{r}{$^{***}$p$<$0.01;$^{**}$p$<$0.05;$^{*}$p$<$0.1} \\ &&\multicolumn{2}{r}\textit{This is the first note of some length}\\ &&\multicolumn{2}{r}\textit{This is the second note probably of larger length}\\ \bottomrule \end{tabular} \end{table}