Hi! I am Mike Marin and in this video we'll introduce multiple
Linear Regression. Multiple Linear Regression is useful for modelling
the relationship between a numeric outcome,dependent
or Y variable and multiple explanatory, independent
or X variables. We will be working with the Lung Capacity data
that was introduced earlier in this series
of videos I've already gone ahead and imported the data
into R and attached it. Our outcome variable will be Lung Capacity.
To fit our linear model we will be using the "lm" command
You can access the help menu by typing "help" and the name of the command in brackets
or by typing the command name directly into the help search window;
We will be working with scripts in R: You can see I have one prepared here.
Having worked through my series of the videos you should be a bit more comfortable using
R at this point. To learn more about writing or saving scripts
in R see my video in series 1 on writing scripts in R.
First, let's fit a linear regression model using Age and Height as our explanatory or
X variables, and let's save this in an object called 'model1'
we'll submit this command here and now let's ask for summary of this model:
Here we can see the R-squared of 0.843, approximately 84% of variation in Lung Capacity
can be explained by our model, that is, it can be explained by Age and Height.
Here we can see the F-statistics and p-value for an overall test of significance of our
model. This test the null hypothesis that all the
model coefficients are 0. In our example here, it tests specifically that
the slope for Age and Height are 0. Here we can see the residual standard error,
this gives us an idea of how far observed Lung Capacities or Y values are from the predicted
or fitted Lung Capacity: the Y-hats. This gives us an idea of the typical sized
residual or error. The intercept of -11.747 is the estimated
mean Y value when all Xs are 0. This would be the estimated mean Lung Capacity
for someone of Age and Height of 0. You'll notice that this doesn't have a very
meaningful interpretation. To give the the intercept a better interpretation,
we can centre Age and Height. This is a topic we'll discuss in following
videos. We can see that the slope for Age is 0.126, this
is the effect of Age on Lung Capacity adjusting or controlling for Height.
We associate an increase of 1 year in Age with an increase of 0.126 in Lung Capacity
adjusting or controlling for the Height. We can also see the hypothesis test that the
slope equal 0 here. The slope for Height is 0.278, this is the
estimated effect of Height on Lung Capacity adjusting for Age.
We can see the test for the hypothesis that the slope for Height is 0 here.
Now, let's go ahead and calculate Pearson's correlation between Age and Height.
We can see that Age and Height are very highly correlated.
The collinearity between Age and Height means that we should not directly interpret the
slopes, say the slope of Age as the effect of Age on Lung Capacity adjusting
for Height. This high correlation between Age and Height
suggests that these two effects are somewhat bounded together.
Dealing with collinearity is a topic we'll discuss in later videos.
And finally as we've seen in earlier videos, we can create a
confidence interval for the model coefficients using the "confint" command.
let's go ahead and take a look at a confidence interval for our model's coefficients.
We have an estimated slope for Age of 0.126, or 95% confident the true slope is between 0.09
and 0.16; Let's go ahead and fit a linear model using
all of our X variables. We'll submit this command here
and now we can ask for summary of our model. We can check the model assumptions by examining
plots of the residuals or errors. To do so we can use the "plot(model)" command.
Taking a look at these plots, here we can see the relationship between Age, Height and Lung Capacity
is approximately linear, the variation looks constant
Lung Capacity given Age and Height is approximately normal.
To learn more about producing and examining these residual plots you can see my earlier
video on examining model assumptions in linear regression.
In the next video in this series, we'll talk more about linear regression and specifically
we will focus our discussion on the inclusion of categorical variables or factors in a linear
model. Thanks for watching this video and make sure
to check out my other instructional videos.