Linear and Logistic Regression for Analysts
Using regression to quantify relationships, control for other factors, and interpret coefficients honestly.
Intermediate · about 6 hours · difficulty 3/5
Learn first: Hypothesis Testing and p-values, Correlation, Causation and Confounding
Regression fits a line (or surface) through data to describe how an outcome changes with one or more inputs. For analysts it is primarily an explanation tool, not a black-box predictor.
Linear regression
- Models a numeric outcome: price, revenue, time spent.
- Each coefficient is the expected change in the outcome for a one-unit change in that input, holding the others constant.
- R-squared says how much variation is explained; low R-squared is normal for human behaviour and does not make a model useless.
- Check residual plots for patterns that suggest a missing variable or non-linear shape.
Logistic regression
Models a yes/no outcome such as churn or conversion. Coefficients are in log-odds; exponentiate them to get odds ratios, which are easier to explain.
Practical tips
- Encode categories as dummy variables and remember one level is the baseline.
- Log-transform skewed variables like income or revenue.
- Watch for multicollinearity: highly correlated inputs make individual coefficients unstable.
- Report confidence intervals on coefficients, not just point estimates.
Tools
Excel's Analysis ToolPak and LINEST work for small cases. In Python, statsmodels gives readable summary tables; scikit-learn focuses on prediction.
Pitfall: interpreting a coefficient as causal just because other variables were "controlled for". Move on when you can fit a multiple regression and explain two coefficients in plain English with their uncertainty.
Key concepts
- Simple and multiple linear regression
- Interpreting coefficients
- R-squared and residuals
- Dummy variables
- Logistic regression and odds ratios
- Log transforms
- Multicollinearity
Mini project
Fit a multiple regression on the Kaggle House Prices (Ames Housing) dataset explaining sale price with size, quality and neighbourhood, and write a short memo interpreting three coefficients.
Check yourself
What does it mean when a coefficient's confidence interval includes zero?
Free resources
- statsmodels documentation (statsmodels)
- OpenIntro Statistics (OpenIntro)
- Statistics and probability (Khan Academy)