Regression Analysis: Linear, Polynomial, and Logistic Regression from a Statistical Perspective
Master regression from a statistical lens — simple and multiple linear regression, polynomial regression, logistic regression, assumptions, diagnostics, and when to use regression vs ML.
Regression Analysis: Linear, Polynomial, and Logistic Regression from a Statistical Perspective
Regression analysis models the relationship between one or more predictors (X) and an outcome (Y). It tells you how Y changes when X changes, provides interpretable coefficients, and lets you make predictions with quantified uncertainty.
---
What Is Regression Analysis?
| Statistical Perspective | Machine Learning Perspective |
|---|---|
| Emphasis on inference: coefficients, SE, p-values | Emphasis on prediction: accuracy, MSE |
| Assumptions must be checked | Often more flexible (e.g., tree-based) |
| Interpretable: "each unit increase in X adds β to Y" | May sacrifice interpretability for performance |
| Confidence intervals for parameters | Prediction intervals for new observations |
---
Simple Linear Regression
Models the relationship between one predictor and one outcome as a straight line.
Equation
Y = β₀ + β₁X + ε
- β₀: Intercept (Y when X = 0)
- β₁: Slope (change in Y per unit increase in X)
- ε: Error term (residual)
Interpreting Coefficients
| Coefficient | Interpretation |
|---|---|
| β₀ | Predicted Y when X = 0 (may not be meaningful if X never equals 0) |
| β₁ | For each 1-unit increase in X, Y changes by β₁ units on average |
R-Squared (R²)
R² = proportion of variance in Y explained by X.
| R² | Interpretation |
|---|---|
| 0.90 | 90% of the variation in Y is explained by X |
| 0.50 | Half the variation explained |
| 0.10 | Weak relationship |
---
Assumptions of Linear Regression
| Assumption | Meaning | How to Check |
|---|---|---|
| Linearity | Relationship between X and Y is linear | Scatter plot of Y vs X; residual plot |
| Independence | Observations are independent | Design of study (no repeated measures, clustering) |
| Homoscedasticity | Constant variance of residuals | Residuals vs fitted plot (no funnel shape) |
| Normality of residuals | Residuals are normally distributed | Q-Q plot of residuals |
| No perfect multicollinearity | Predictors are not perfectly correlated | Correlation matrix; VIF (see below) |
---
Multiple Linear Regression
Adds more predictors to the model.
Y = β₀ + β₁X₁ + β₂X₂ + ... + βₖXₖ + ε
Interpreting Coefficients
Each βⱼ is the change in Y for a 1-unit increase in Xⱼ, holding all other predictors constant.
Example: Y = 30 + 2X₁ − 0.5X₂. For each extra unit of X₁ (holding X₂ fixed), Y increases by 2. For each extra unit of X₂ (holding X₁ fixed), Y decreases by 0.5.
---
Polynomial Regression
Models non-linear relationships by adding powers of X.
Y = β₀ + β₁X + β₂X² + β₃X³ + ...
- Quadratic (X²): Captures one bend (e.g., U-shape)
- Cubic (X³): Captures two bends
Caution: Higher orders can overfit. Prefer the simplest model that fits well.
---
Logistic Regression
For binary outcomes (Yes/No, Success/Failure). Models the probability that Y = 1.
Equation (Logit Form)
log(odds) = log(p/(1−p)) = β₀ + β₁X₁ + ...
The sigmoid function converts the linear combination to a probability between 0 and 1:
P(Y=1) = 1 / (1 + e^{-(β₀ + β₁X)})
Interpreting Coefficients: Odds Ratios
For a 1-unit increase in X, the odds of Y=1 multiply by e^β.
| β | Odds Ratio (e^β) | Interpretation |
|---|---|---|
| 0.5 | 1.65 | 65% increase in odds |
| −0.5 | 0.61 | 39% decrease in odds |
| 0 | 1 | No change |
---
Checking Assumptions
Residual Plots
| Plot | What to Look For |
|---|---|
| Residuals vs Fitted | Random scatter around 0; no patterns (curves, funnel) |
| Residuals vs Each Predictor | No systematic pattern |
| Scale-Location | Spread of residuals should be roughly constant |
Q-Q Plot (Normality)
Points should roughly follow a straight line. Heavy tails or skew indicate non-normality.
What to Do If Assumptions Fail
| Violation | Possible Fix |
|---|---|
| Non-linearity | Add polynomial terms, transform X or Y |
| Heteroscedasticity | Transform Y (e.g., log), use weighted least squares |
| Non-normal residuals | Larger samples often OK (CLT); consider robust SEs |
| Outliers | Investigate; consider robust regression or exclusion |
Multicollinearity (VIF)
When predictors are highly correlated, coefficient estimates become unstable and hard to interpret.
VIF (Variance Inflation Factor): VIF > 5 (or 10) suggests problematic multicollinearity.
| VIF | Action |
|---|---|
| 1–5 | Generally acceptable |
| 5–10 | Consider removing or combining predictors |
| > 10 | Strong multicollinearity; drop or transform |
When to Use Regression vs ML
| Use Regression When | Use ML When |
|---|---|
| You need interpretable coefficients | Prediction accuracy is the top priority |
| Sample size is modest | Large data; complex non-linear patterns |
| Assumptions are met (or close) | Assumptions are hard to satisfy |
| Inference (CI, p-values) matters | Only prediction matters |
| Linear or simple non-linear relationships | Highly complex, interactive effects |
---
Common Pitfalls
| Pitfall | Avoid By |
|---|---|
| Extrapolating | Stay within the range of your X data |
| Ignoring assumptions | Always check residual and Q-Q plots |
| Overfitting with polynomials | Use cross-validation; prefer simpler models |
| Collinearity | Check VIF; drop or combine correlated predictors |
| Confusing correlation with causation | Regression shows association; causation needs design |
| Omitting important predictors | Consider confounders; use domain knowledge |
Quick Reference
| Model | Outcome | Key Assumption |
|---|---|---|
| Linear | Continuous Y | Linear relationship, normal residuals |
| Polynomial | Continuous Y | Same as linear; add X², X³ for curvature |
| Logistic | Binary Y (0/1) | Linear in log-odds; no normality of Y |
| Diagnostic | Purpose |
|---|---|
| R² | Variance explained |
| Residual plot | Linearity, homoscedasticity |
| Q-Q plot | Normality of residuals |
| VIF | Multicollinearity |
What's Next?
- [Statistics Overview](statistics-overview) — The statistics workspace
- [Statistical Tests Guide](statistical-tests-guide) — Hypothesis tests for model coefficients
- [ML Algorithms Guide](ml-algorithms-guide) — When to move from regression to ML
- [Probability Distributions](probability-distributions) — Understanding residual distributions
Related Articles
Statistics Overview: What Are Statistics and How to Use Them
A beginner-friendly introduction to statistics, descriptive vs inferential analysis, the Statistics workspace layout, and running your first analysis.
Statistical Tests
A complete guide to all 14+ hypothesis tests -- when to use each one, how to run them, and how to interpret results.
ML Algorithms: All 15+ Explained in Plain English
Plain-English explanations of Linear/Ridge/Lasso/Elastic Net, Logistic Regression, Decision Tree, Random Forest, XGBoost, LightGBM, SVM, KNN, Naive Bayes, Neural Network, AdaBoost, Extra Trees—with pros, cons, and a comparison table.
Probability Distributions: Understanding How Data Is Shaped
Learn about the most important probability distributions — Normal, Binomial, Poisson, Uniform, and Exponential — and how they help you understand and model real-world data.
Was this helpful?