
Image by Editor (Kanwal Mehreen) | Canva
When building a regression model using Python’s statsmodels library, a key feature is the detailed summary table that is printed after fitting a model. This summary provides a comprehensive set of statistics that helps you assess the quality, significance, and reliability of your model.
In this article, we’ll walk through the major sections of a regression summary output in statsmodels and explain what each part means.
Fitting a Model with statsmodels
Before you can get a summary, you need to fit a model. Here’s a basic example:
import statsmodels.api as sm
import pandas as pd
# Example data
df = sm.datasets.get_rdataset('mtcars').data
X = sm.add_constant(df[['hp', 'wt']]) # Independent variables with constant
y = df['mpg'] # Dependent variable
# Fit the model
model = sm.OLS(y, X).fit()
# Show the summary
print(model.summary())
Output:
OLS Regression Results
==============================================================================
Dep. Variable: mpg R-squared: 0.827
Model: OLS Adj. R-squared: 0.815
Method: Least Squares F-statistic: 69.21
Date: Fri, 18 Jul 2025 Prob (F-statistic): 9.11e-12
Time: 13:51:31 Log-Likelihood: -74.326
No. Observations: 32 AIC: 154.7
Df Residuals: 29 BIC: 159.0
Df Model: 2
Covariance Type: nonrobust
==============================================================================
coef std err t P>|t| [0.025 0.975]
------------------------------------------------------------------------------
const 37.2273 1.599 23.285 0.000 33.957 40.497
hp -0.0318 0.009 -3.519 0.001 -0.050 -0.013
wt -3.8778 0.633 -6.129 0.000 -5.172 -2.584
==============================================================================
Omnibus: 5.303 Durbin-Watson: 1.362
Prob(Omnibus): 0.071 Jarque-Bera (JB): 4.046
Skew: 0.855 Prob(JB): 0.132
Kurtosis: 3.332 Cond. No. 588.
==============================================================================
Interpreting the Summary Table
Let’s now explore each section of the summary() output.
1. Model Information (Top Block)
- Dep. Variable: The dependent or target variable being predicted, which in this example is mpg.
- Model: The type of regression used, which is Ordinary Least Squares (OLS).
- R-squared: The proportion of variance in the dependent variable explained by the model.
- Adj. R-squared: R-squared adjusted for the number of predictors; more reliable when comparing models.
- F-statistic / Prob (F-statistic): A test of overall model significance, meaning at least one predictor has a meaningful effect on the outcome.
- AIC (Akaike Information Criterion): AIC helps compare multiple models by balancing fit and complexity.
- BIC (Bayesian Information Criterion): BIC also compares models but penalizes complexity more heavily than AIC.
2. Coefficient Table (Middle Block)
- coef: The estimated regression coefficient. A positive value means a positive relationship with the dependent variable.
- std err: The standard error of the coefficient, which measures the uncertainty in its estimate.
- t: Tests whether a coefficient is significantly different from zero.
- P>|t|: The p-value for the t-test. A low p-value (commonly < 0.05) suggests the predictor is statistically significant.
- [0.025, 0.975]: The 95% confidence interval for the coefficient. If this range does not include zero, the effect is likely statistically significant.
3. Model Diagnostics (Bottom Block)
- Omnibus / Prob(Omnibus): A test for the normality of residuals. A high p-value (greater than 0.05) suggests normality, which is desirable.
- Durbin-Watson: Tests for autocorrelation in the residuals. Values close to 2 suggest that there is no autocorrelation.
- Jarque-Bera: Another test for the normality of residuals, similar to Omnibus. A high p-value also supports the assumption of normality here.
- Skew / Kurtosis: Measures the shape of the residual distribution. Skew measures asymmetry, while kurtosis indicates whether residuals are heavy- or light-tailed.
- Cond. No.: Refers to potential multicollinearity problems. Values above 30 may signal that the model has unstable or highly correlated predictors.
Key Takeaways for Interpretation
- Look for low p-values (< 0.05) in the coefficient table to identify significant predictors.
- A high R-squared indicates a good fit, but watch for overfitting with many predictors.
- Check diagnostic metrics to validate regression assumptions (normality, independence, and multicollinearity).
- Use confidence intervals to assess the precision of your estimates.
Conclusion
The regression summary indicates that the model fits the data reasonably well, as evidenced by the R-squared and adjusted R-squared values. Significant predictors are identified by p-values less than 0.05. The sign and magnitude of each coefficient indicate the direction and strength of the relationship. The F-statistic and its p-value confirm whether the overall model is statistically significant. If the key assumptions of linear regression are met, the model is suitable for inference and prediction.
