Quant500 Academy

3. Simple linear regression: finding the best line

Level 4: Correlation, regression and the myth of causality

The sector rose 2%. The model predicted 2.65% for the airline. The airline did 1.9%.

That gap of 0.75 percentage points is not a failure of the method. It is one of the most useful pieces of information a regression produces.

From describing to estimating

Correlation tells you whether two variables move together and how strongly. What it does not give you is a tool for estimating one from the other.

That is exactly what simple linear regression does. It looks for the line that best sums up how one variable —the dependent one— behaves as a function of another —the independent one—, so that you can use it to describe, and to some extent predict, their joint behavior.

The two numbers that define the line

Take a concrete example. You want to describe how the daily return of an airline moves as a function of the daily return of the transport sector index, using 60 sessions of data.

The line the regression looks for has this form, in words:

estimated return of the share = a base value (called the intercept) plus a slope multiplied by the sector return that same day.

The intercept and the slope are the only two numbers that completely define that line.

Least squares

To find that particular line among all the possible ones, regression uses the criterion of least squares.

For each of the 60 days, the line predicts a return. That predicted value almost never coincides exactly with the real observed return, and the difference between the two is called the residual, or error.

The regression chooses, out of all imaginable lines, the one that makes the sum of those residuals squared as small as possible.

Why square them instead of just adding the errors up as they are? For three reasons:

The line, with numbers

Let us look at a numerical example. Suppose the regression, applied to those 60 sessions, yields this line:

estimated return of the airline = 0.05% + 1.3 times the sector return.

Read it in three scenarios:

That residual is the part of that day's move which the model failed to explain.

Residuals are information

It is important to understand that the fitted line almost never passes exactly through every data point. Nor does it need to: its aim is not to memorize the sample, but to sum up the general tendency of the relationship.

And what falls outside the line, the residuals, is not a failure of the method. It is information.

It is the part of the share's behavior that responds to company-specific factors, particular news items or plain noise, and not to the sector's movement.

Look at the chart before believing the line

One last caution. Simple linear regression assumes that the relationship between the two variables is reasonably straight.

If, when you plot the points on a chart, the cloud traces a pronounced curve, the least squares procedure will still hand you "the best possible line" in mathematical terms.

But that line may describe the real underlying relationship badly, and lead to mistaken conclusions if it is used to predict.

Before trusting a regression, it is worth looking at the scatter plot, not just the final number.

The rest of Quant500

What you are learning, applied to the index every day:

The model portfolio, weekly in your inbox

Every Saturday, its week in one minute: how it went, the best and the worst, and which insiders bought with their own money. Plus, the day the model is rebuilt, which stocks come in and which go out. A simulation, not advice. At most one email a week, no ads, no account; one-click unsubscribe. Made by one person: Pol Gracia.

A model portfolio with simulated results, not a personalized recommendation. Your email is used for this only: privacy.

Behind the Academy and the rest of Quant500 there is one person: Pol Gracia Serrahima.