Intermediate Regression with statsmodels in Python
Fit linear and logistic regression models with several explanatory variables and interactions in Python with statsmodels, then code the algorithms yourself.
Linear and logistic regression with several explanatory variables are the subject here. You fit both kinds of model in Python with statsmodels, see how an interaction between two variables changes predictions, meet Simpson’s Paradox, and write your own fitting algorithms to see how the estimates are found.
What You Will Achieve
- Fit a regression with one numeric and one categorical explanatory variable and interpret its coefficients
- Add an interaction term to a model and calculate its predictions by hand
- Judge which of two models fits better from the coefficient of determination and residual standard error
- Code linear and logistic regression algorithms yourself, based on the sum of squares and the log-likelihood
Program Overview
Parallel Slopes and Interaction Models
Adds a category to a numeric predictor, then lets one variable change the effect of another for more realistic predictions.
- Fitting and visualizing parallel slopes models
- One model per category versus one model with an interaction
- Comparing model performance
- Simpson’s Paradox and eBay auction data
Multiple Linear Regression with Numeric Variables
Works with two or more numeric explanatory variables and closes with a linear regression algorithm written by hand.
- Interactive 3D scatter plots and plots of many variables
- Different levels of interaction
- Sum of squares and the linear regression algorithm
Multiple Logistic Regression and the Logistic Distribution
Extends logistic models to several explanatory variables, explains the distribution behind them and ends with your own logistic regression algorithm.
- Logistic predictions and the confusion matrix
- Cumulative and inverse cumulative distribution functions
- Likelihood, log-likelihood and the logistic regression algorithm
Certificate Awarded (Paid)
Job Outlook
Regression with several explanatory variables is used in data analysis, statistics and research work wherever a prediction or explanation rests on more than one factor, such as house prices or whether a customer churns.
Good for: Python learners who want to model outcomes that depend on several variables and to see how linear and logistic regression are actually computed.
Keep in mind: Three of the four chapters are on linear models; multiple logistic regression and the logistic distribution share the final chapter.
Bottom line: Its strength is pairing statsmodels practice with hand-built algorithms, so you learn both how to fit these models and where their estimates come from.
Frequently Asked Questions
What data are the regression models fitted to?
The exercises work with real-world data, including Taiwan house prices and a customer churn dataset, plus eBay auction data in the lessons that model each auction type separately.
What is Simpson's Paradox?
It is a counterintuitive result in which a trend seen across the whole dataset reverses once the data is split into groups. You meet it in the chapter on interactions, where adding explanatory variables brings it to the surface.
How are models with many variables visualized?
Lessons plot each explanatory variable on its own, draw parallel slopes and per-category models, use an interactive 3D scatter plot for two numeric predictors, and show ways to display many variables at once.
How is a logistic model's performance checked?
The final chapter covers the confusion matrix, after lessons on making predictions from a logistic model with two explanatory variables and on visualizing several explanatory variables.
User Reviews
Write your review
You must be logged in to post a review.
Reviews can only be posted by registered learners. Log in or create a free account, then you will return here to post.


There are no reviews yet.