liveBook · Manning

Statsmodels

As explained in Statistics Every Programmer Needs

A Python library for statistical modeling, estimation, hypothesis testing, and statistical data exploration.

statsmodels supports statistical modeling in Python alongside pandas, NumPy, SciPy, Matplotlib, seaborn, and scikit-learn. Its demonstrated role is fitting interpretable regression models and inspecting statistical output. section 1.2.1 section 4.2.2

Core workflows include:

  • Fit ordinary least squares regression with sm.OLS(y, x).fit(), adding an intercept explicitly with sm.add_constant(). section 4.2.2
  • Fit logistic regression with smf.logit(...).fit() and inspect coefficients, p-values, likelihood statistics, and goodness-of-fit measures. section 5.2.2
  • Investigate multicollinearity with auxiliary OLS regressions and variance inflation factors, then compare reduced predictor sets. section 5.2.2

Predicting split times

Regress stage2 against stage1, fit the model, and print its regression table: lm = sm.OLS(y, x).fit(); print(lm.summary()). The output includes R-squared, coefficients, standard errors, t statistics, and information criteria. section 4.2.2

>>> import statsmodels.api as sm
>>> y = mds['stage2']

Use the compact listing to trace imports, response-variable selection, and the first OLS setup. section 4.2.2

How Statistics Every Programmer Needs covers it

How deep it goes
Explains model fitting, output interpretation, significance testing, multicollinearity checks, and reduced-model comparison.
Examples
Uses stage split-time prediction and raisin-variety classification with morphological predictors.
What it assumes
Assumes Python data structures and predictors-response framing while introducing OLS, intercepts, significance tests, and VIF procedures.
What you can do after
Build linear and logistic regression models, inspect statistical summaries, and diagnose predictor collinearity.
How it connects
Connects linear regression, logistic regression, ordinary least squares, multicollinearity, and variance inflation factor analysis.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Statistics Every Programmer Needs. The section links point to the parts of the book it draws on.