Skip to main content

Menu

LEVEL 0
0/5 XP
HomeAboutTopicsPricingMy VaultStats

Categories

🤖 Artificial Intelligence
☁️ Cloud and Infrastructure
💾 Data and Databases
💼 Professional Skills
🎯 Programming and Development
🔒 Security and Networking
📚 Specialized Topics
HomeAboutTopicsPricingMy VaultStats
LEVEL 0
0/5 XP
GitHub
© 2026 CheatGrid™. All rights reserved.
Privacy PolicyTerms of UseAboutContact

Statsmodels Cheat Sheet

Statsmodels Cheat Sheet

Back to Data Science
Updated 2026-03-19
Next Topic: Streamlit Data Application Framework Cheat Sheet

Statsmodels is Python's inference-focused statistics and econometrics library, sitting on top of NumPy, SciPy, pandas, and Patsy. It matters because it combines model estimation with the outputs practitioners actually need for analysis: standard errors, hypothesis tests, diagnostics, confidence intervals, and interpretable summaries. A useful mental model is that statsmodels is less about black-box prediction and more about specifying the model carefully, checking assumptions, and defending the conclusions after fitting.

What This Cheat Sheet Covers

This topic spans 10 focused tables and 118 indexed concepts. Below is a complete table-by-table outline of this topic, spanning foundational concepts through advanced details.

Table 1: Core APIs and WorkflowTable 2: Linear and Robust Regression ModelsTable 3: GLM, Correlated Data, and Smooth ModelsTable 4: Discrete, Count, and Limited Dependent Variable ModelsTable 5: Hypothesis Tests, ANOVA, and Multiple ComparisonsTable 6: Regression Diagnostics and Inference ChecksTable 7: Time Series Diagnostics and DecompositionTable 8: Univariate Forecasting and Structural Time SeriesTable 9: Multivariate, State Space, and Regime-Switching ModelsTable 10: Nonparametric, Survival, and Custom Modeling

Table 1: Core APIs and Workflow

MethodExampleDescription
statsmodels.api
import statsmodels.api as sm
Main import surface for matrix-based model classes, datasets, graphics, and statistical tools.
statsmodels.formula.api
import statsmodels.formula.api as smf
Formula interface using R-style formulas and Patsy design matrices.
add_constant
X = sm.add_constant(X)
Adds an explicit intercept column for matrix-based models that do not include one by default.
from_formula
sm.OLS.from_formula('y ~ x1 + x2', data=df)
Alternate constructor that builds the design matrix from a formula and DataFrame.
fit
res = sm.OLS(y, X).fit()
Estimates the model and returns a results object with inference and diagnostics.
summary
res.summary()
Produces the standard text summary with coefficients, tests, fit metrics, and diagnostics.

More in Data Science

  • Statistical Inference Tests Cheat Sheet
  • Streamlit Data Application Framework Cheat Sheet
  • AB Testing and Online Experimentation Cheat Sheet
  • Design of Experiments (DOE) Cheat Sheet
  • Network Analysis with NetworkX Cheat Sheet
  • R for Data Science and Tidyverse Cheat Sheet
View all 47 topics in Data Science