Hello. Welcome back to the course.
Super excited to have you on board today.
We've got a very interesting and important tutorial.
Assumptions of linear regression.
So let's have a look.
Here we've got a data set.
With a linear regression applied.
And this linear regression seems to be serving its purpose really well.
However if we look at the following three data sets,
we can see that a linear regression is applied each time.
And in fact it's exactly the same linear regression as in the first case.
However, those linear regressions are not serving their purpose.
In fact, they are misleading.
So we shouldn't be using linear regressions in those situations.
These four data sets are called the Anscombe Quartet,
and they illustrate that you can't just simply blindly apply linear regression.
You have to make sure that your data set is fit for using linear regression.
And that's where assumptions of linear regression come in.
So let's have a look at them.
There's going to be five assumptions in total plus an extra check.
The first assumption is linear.
We want to make sure that there is a linear relationship
between our dependent variable and each independent variable.
And if you look at the chart
here on the right, you'll see that the linear regression is misleading.
It is.
There is actually no linear relationship between the two variables.
So we wouldn't use this kind of model there.
The second assumption is homoscedasticity.
And even though
it sounds like a complex term, it actually simply means equal variance,
meaning that you don't want to see a cone type shape
on your chart with an increasing cone and decreasing cone,
which would mean that variance is dependent on the independent variable.
So in this case we wouldn't use a linear regression either.
The third assumption is multivariate normality
or normality of error distribution. If you look at the chart
here on the right, you can feel that something is off.
The best way to intuitively think about it is
if you look along the line of the linear regression,
you want to see a normal distribution of your data points.
In the case on the right here, we can see something different.
And so again we wouldn't apply a linear regression there.
The fourth assumption is independence of observations.
And this includes the term no autocorrelation.
Sometimes you'll see this assumption titled as no autocorrelation.
And what that means is that we don't want
to see any kind of pattern in our data pattern in the data
like we see here indicates that our rows are not independent,
that some rows are affecting other rows and other rows, etc..
A classic example of this would be the stock market, where
previous prices of future prices which affect future prices and so on.
So in this case, we wouldn't apply a linear regression model.
The fifth assumption is lack of multicollinearity.
Basically we want our independent variables or predictors
not to be correlated with each other if they're not correlated
then we can build a linear regression.
If they are correlated
then if we do proceed and build a linear regression model, then the coefficient
estimates that we get in the model will become unreliable.
And the sixth point is the outlier check.
This is not an actual assumption, but rather an extra check.
That is important to keep in mind when building linear regression models.
If you look at the chart here on the right, you can see that the outlier
is significantly affecting the linear regression line that we get.
So something that we want to consider is
should we remove the outliers before building a linear regression.
Or do we want to build a linear regression with the outliers included?
This will depend on your business knowledge and knowledge of the data set.
So there we go.
Those are the assumptions of linear regression.
In this course we're going to assume by default
that they are correct for all the data sets that we work with.
However, when you're working with your own data sets, it's important
to do these checks to make sure you're building a linear regression.
When it is fit for the data set.
And to finish off this tutorial, I have a special bonus for you.
If you enjoyed this explanation, you can download the PDF
version of this slide and keep it at home printed out as a poster.
Keep it somewhere handy
for those times when you do need to check assumptions of linear regression.
If that's something that you would like to have.
Head on over to Super Data
science.com/assumptions and you can download your poster there.
And I look forward to seeing you back here next time.
Until then, enjoy machine learning.