Tables

estimagic.visualization.estimation_table.estimation_table(models, return_type, render_options=None, custom_param_names=None, show_col_names=True, custom_col_names=None, custom_model_names=None, custom_index_names=None, show_inference=True, confidence_intervals=False, show_stars=True, sig_levels=(0.1, 0.05, 0.01), sig_digits=2, left_decimals=1, show_footer=True, stats_dict=None, append_notes=True, notes_label='Note:', custom_notes=None, siunitx_warning=True, alignment_warning=True)[source]

Generate html and LaTex tables provided (lists of) of models.

Can return strings of LaTex/html scripts or dictionaries with processed dataframes to be passed to tabular functions, or save tables to path.

Parameters
  • models (list) – list of estimation results. The estimation results should either have attributes info(dict) with summary statistics of the model and params (DataFrame) with parameter values, standard erors and/or confidence intervals and p values, or a sm regression result can be passed.

  • return_type (str) – Can be “latex”, “html”, “python” or a file path with the extension .tex or .html. If “python”, a dictionary with the entries “paramaters_df”, “footer_df” and “footer (html and latex)” is returned.

  • render_options (dict) – A dictionary with keyword arguments that are passed to df.to_latex or df.to_html, depending on the return_type. The default is None.

  • show_col_names (bool) – a boolean variable for printing column numbers. Default is True

  • custom_col_names (list) – a list of strings to print as column names. Default is None.

  • custom_model_names (list) – a list of strings to print as model names, possibly combining columns under common model names. Default is None.

  • custom_index_names (list) – a list of strings to print as the name of the parameter/variable column. To print index names, add index_names = True in the render options. Default is None.

  • show_inference (bool) – a boolean variable for printing precision (standard error/confidence intervals). Defalut is True.

  • show_stars (bool) – a boolean variable for printing significance stars. Default is True.

  • sig_levels (list) – a list of floats for p value’s significance cutt-off values. Default is [0.1,0.05,0.01].

  • sig_digits (int) – an integer for the number of digits to the right of the decimal point to round to. Default is 2.

  • left_decimals (int) – an integer used for aligning LaTex columns. Affects the alignment of the columns to the left of the decimal point of numerical entries. Default is 1.

  • confidence_intervals (bool) – a boolean variable for printin confidence intervals or standard errors as precision. If False standard errors are printed. Default is False.

  • show_footer (bool) – a boolean variable for printing statistics, e.g. R2, Obs numbers. Default is True.

  • stats_dict (dict) – a dictionary with printed statistics names as keys, and statistics statistics names to be retrieved from model.info as values. Default is dictionary with common statistics of stats model linear regression.

  • append_notes (bool) – a boolean variable for printing p value cutoff explanation and additional notes, if applicable. Default is True.

  • notes_label (str) – a sting to print as the title of the notes section, if applicable. Default is ‘Notes’

  • custom_notes (list) – a list of strings for additional notes. Default is None.

Returns

depending on the rerturn type, a string

for html or latex tables, or a dictionary with atatistics and parameters dataframes, and strings for footers is returned. If the return type is a path, the function saves the resulting table at the given path.

Return type

res_table (str or dictionary)

Notes

  • Compiling LaTex tables requires the package siunitx.

  • Add sisetup{input-symbols = ()} to your main tex file for proper

    compilation

  • If the number of models is more than 2, set the value of left_decimals

    to 3 or more to avoid columns overlay in the tex output.