Simple Linear Regression
A visual step-by-step guide to the key concepts in a linear regression model
Linear regression is one of the most foundational tools in econometrics and data science. We use it to either infer relationships between variables or to make predictions.
It models the relationship between a dependent variable and one or more independent variables by fitting a straight line through the data.
The idea is simple: given some data, find the line that best summarises the trend. But what does "best" mean? How do we measure it? And how confident can we be in the result? These notes walk through the intuition, step by step.
The Data and the Question
Meet the dataset and try to find the pattern
Measuring the Errors
How do we know if a line is good or bad?
The OLS Solution
Step-by-step hand calculation of the best line
Evaluating the Model Fit
TSS, SSR, SSE, R², and making predictions
Can We Trust the Estimates?
Standard errors, t-tests, and confidence intervals
Python Code
Reproduce the full case study in Python — from raw data to inference
References & Further Reading
Books, articles, and resources to deepen your understanding