statsmodels / statsmodels/statsmodels
[ENH] Add Great Tables export for regression results (Results.as_gt())
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 11.6k
- Forks
- 3.6k
- Avg merge
- 7h 37m
- Merged PRs (30d)
- 96
Description
Is your feature request related to a problem? Please describe
Many users need publication-quality regression tables for papers, reports, and notebooks/Quarto. The existing .summary() text/HTML/LaTeX outputs are helpful, but reaching journal-style tables typically requires additional manual formatting and post-processing. A direct bridge from Results objects to a high-level table library would streamline reproducible workflows.
Describe the solution you'd like
Add a first-class export path from statsmodels Results objects to the Great Tables Python package:
- API:
- New method:
Results.as_gt()returning aGTobject (optional dependency). - Initially support common result classes: OLS/GLM/Logit/Probit; design API so more models can be added.
- New method:
- Content mapping:
- Columns: coefficient, std. error, test statistic (t or z), p-value, and confidence interval.
- Model-level stats in header/footnotes: N, R² (or pseudo-R²), AIC, BIC, log-likelihood, etc.
- Options:
- Significance markers, decimal formatting, variable/term labeling, column spanners, notes/footnotes.
- Multi-model stacking (e.g., helper to combine multiple
Resultsinto one table).
- Packaging:
- Keep Great Tables as an optional dependency; if not installed, raise a clear ImportError with an install hint.
- Tests & docs:
- Unit tests (including smoke tests) for supported models and options.
- A gallery/example notebook rendering the table to HTML/PDF.
Describe alternatives you have considered
- Using
.summary()(text/HTML/LaTeX) and then hand-tuning formatting and layout; this works but is verbose and brittle for repeated use. - Exporting values to pandas DataFrames and building tables manually; flexible but requires users to re-implement common conventions (e.g., stars, CI formatting, model stats).
- Third-party exporters or custom scripts that duplicate logic across projects.
Additional context
- Happy to implement this feature and open a WIP PR for early API review.
- Open questions for maintainers:
- Preferred location: a method on
Resultsvs. a helper instatsmodels.iolib. - Exact set of model-level statistics to include by default for each family.
- Defaults for significance notation and number formatting.
- Preferred location: a method on
- Backwards compatibility: this is additive and opt-in; no changes to existing
.summary()behavior are proposed.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the existing Results.summary() export paths and the proposed statsmodels.iolib location, then compare the common OLS, GLM, Logit, and Probit result interfaces. Define the API and defaults with maintainers before implementing. Done means supported Results objects return Great Tables objects, missing dependencies produce a clear install hint, and the requested options, tests, and gallery example are covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- data
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100