All Projects → mwburke → stargazer

mwburke / stargazer

Licence: other
Python implementation of the R stargazer multiple regression model creation tool

Programming Languages

Jupyter Notebook
11667 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to stargazer

elte-ik-pti-bsc-zarovizsga
ELTE IK - Programtervező Informatikus BSc Záróvizsga tételek kidolgozása
Stars: ✭ 26 (-74.51%)
Mutual labels:  latex
node-latex
🧾 A utility for running LaTeX subprocesses in Node.
Stars: ✭ 31 (-69.61%)
Mutual labels:  latex
sympy-paper
Repo for the paper "SymPy: symbolic computing in python"
Stars: ✭ 42 (-58.82%)
Mutual labels:  latex
pape-rs
A Latex template to PDF generation web service written in Rust.
Stars: ✭ 69 (-32.35%)
Mutual labels:  latex
latex2unicode
Convert LaTeX markup to Unicode (in Scala and Java)
Stars: ✭ 28 (-72.55%)
Mutual labels:  latex
ntuthesis
台大碩博士論文模板 (R Package)
Stars: ✭ 14 (-86.27%)
Mutual labels:  latex
pdfcount
An R Shiny App to Count Words in a PDF Document
Stars: ✭ 26 (-74.51%)
Mutual labels:  latex
xelatex-guide-book
xelatex book template
Stars: ✭ 59 (-42.16%)
Mutual labels:  latex
cv
My curriculum vitae
Stars: ✭ 24 (-76.47%)
Mutual labels:  latex
wizpen
A font based on the Pigpen cipher, originally used to help liberate Wraxnia from the Fangs in a D&D campaign. Works in LaTeX.
Stars: ✭ 15 (-85.29%)
Mutual labels:  latex
alfred-latex-symbols-workflow
🔎 Alfred 3-4 workflow to search for latex symbol commands
Stars: ✭ 33 (-67.65%)
Mutual labels:  latex
bonaparticle
The LaTeX magazine class that doesn’t get in your way.
Stars: ✭ 20 (-80.39%)
Mutual labels:  latex
latex-emoji
Emoji support in (Lua)LaTeX
Stars: ✭ 32 (-68.63%)
Mutual labels:  latex
vimtips
📖 Tips for Vim
Stars: ✭ 31 (-69.61%)
Mutual labels:  latex
Fluentmark
FluentMark -- Eclipse editor for Markdown content
Stars: ✭ 29 (-71.57%)
Mutual labels:  latex
ThinkRubyBuild
Forked from https://github.com/AllenDowney/ThinkPython2
Stars: ✭ 27 (-73.53%)
Mutual labels:  latex
dotwhisker
Dot-and-Whisker Plots of Regression Results
Stars: ✭ 51 (-50%)
Mutual labels:  regression-models
cryptography
Cryptography course slides at Harbin Institute of Technology
Stars: ✭ 86 (-15.69%)
Mutual labels:  latex
redesocial
Projeto do Curso de Sistemas de Informação sobre Rede Social
Stars: ✭ 38 (-62.75%)
Mutual labels:  latex
cmake-cheatsheet
CMake Cheat Sheet
Stars: ✭ 37 (-63.73%)
Mutual labels:  latex

Stargazer

This is a python port of the R stargazer package that can be found on CRAN. I was disappointed that there wasn't equivalent functionality in any python packages I was aware of so I'm re-implementing it here.

There is an experimental function in the statsmodels.regression.linear_model.OLSResults.summary2 that can report single regression model results in HTML/CSV/LaTeX/etc, but it still didn't quite fulfill what I was looking for.

The python package is object oriented now with chained commands to make changes to the rendering parameters, which is hopefully more pythonic and the user doesn't have to put a bunch of arguments in a single function.

Installation

You can install this package through PyPi with pip install stargazer or just clone the repo and take the stargazer.py file since it's the only one in the package.

Dependencies

It depends on statsmodels, which in turn depends on several other libraries like pandas, numpy, etc

Editing Features

This library implements many of the customization features found in the original package. Examples of most can be found in the examples jupyter notebook and a full list of the methods/features is here below:

  • title: custom title
  • show_header: display or hide model header data
  • show_model_numbers: display or hide model numbers
  • custom_columns: custom model names and model groupings
  • significance_levels: change statistical significance thresholds
  • significant_digits: change number of significant digits
  • show_confidence_intervals: display confidence intervals instead of variance
  • dependent_variable_name: rename dependent variable
  • rename_covariates: rename covariates
  • covariate_order: reorder covariates
  • reset_covariate_order: reset covariate order to original ordering
  • show_degrees_of_freedom: display or hide degrees of freedom
  • custom_note_label: label notes section at bottom of table
  • add_custom_notes: add custom notes to section at bottom of the table
  • add_line: add a custom line to the table
  • append_notes: display or hide statistical significance thresholds

These features are agnostic of the rendering type and will be applied whether the user outputs in HTML, LaTeX, etc

Example

Here is an examples of how to quickly get started with the library. More examples can be found in the examples.ipynb file in the github repo. The examples all use the scikit-learn diabetes dataset, but it is not a dependency for the package.

OLS Models Preparation

import pandas as pd
from sklearn import datasets
import statsmodels.api as sm
from stargazer.stargazer import Stargazer

diabetes = datasets.load_diabetes()
df = pd.DataFrame(diabetes.data)
df.columns = ['Age', 'Sex', 'BMI', 'ABP', 'S1', 'S2', 'S3', 'S4', 'S5', 'S6']
df['target'] = diabetes.target

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()


stargazer = Stargazer([est, est2])

HTML Example

stargazer.render_html()
Dependent variable: target
(1)(2)
ABP416.674***397.583***
(69.495)(70.870)
Age37.24124.704
(64.117)(65.411)
BMI787.179***789.742***
(65.424)(66.887)
S1197.852
(143.812)
S2-169.251
(142.744)
Sex-106.578*-82.862
(62.125)(64.851)
const152.133***152.133***
(2.853)(2.853)
Observations442442
R20.4000.403
Adjusted R20.3950.395
Residual Std. Error59.976 (df=437)59.982 (df=435)
F Statistic72.913*** (df=4; 437)48.915*** (df=6; 435)
Note:*p<0.1; **p<0.05; ***p<0.01

LaTeX Example

stargazer.render_latex()

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].