Skip to main content
4 of 4
added 2580 characters in body
Isabella Ghement
  • 20.9k
  • 2
  • 37
  • 60

In addition to @DaveT's helpful answer, here are a few more clarifications regarding the estimated intercepts in your models.

Model 1

The (true) intercept in your first model

lm(mpg ~ 1, data=mtcars)

represents the mean value of mpg for all cars represented by the ones included in this data set, regardless of their displacement (disp) or horse power (hp). In this sense, the (true) intercept is simply the unconditional mean of mpg. Based on the data, its value is estimated to be 20.091.

Model 2

The (true) intercept in your second model:

 lm(mpg ~ disp, data=mtcars)

represents the mean value of mpg for all cars represented by the ones included in this data set which share the same displacement (disp) value of 0. This intercept is estimated from the data to be 29.599855. Because displacement is a measure of the engine size of a car, it doesn't make sense that you would have a car with a displacement of 0, suggesting that the intercept interpretation in this model is meaningless in the real world.

To get a meaningful interpretation for the intercept in your second model, you could center the disp variable around its observed mean value in the data (presuming disp has an an approximately normal distribution) and re-fit the model:

disp.cen <- mtcars$disp - mean(mtcars$disp)


lm(mpg ~ disp.cen, data=mtcars)

In the re-fitted second model, the intercept will represent the mean value of mpg for all cars represented by the ones included in this data set which have a "typical" displacement (disp). Here, a "typical" displacement means the average displacement observed in the data.

Model 3

The (true) intercept in your third model:

 lm(mpg ~ disp + hp, data=mtcars))

represents the mean value of mpg for all cars represented by the ones included in this data set which share the same displacement (disp) value of 0 and the same horse power (hp) value of 0. This intercept is estimated from the data to be 30.735904. Because displacement is a measure of the engine size of a car and horse power is a measure of the engine power of a car, it doesn't make sense that you would have a car with a displacement of 0 and a horse power of 0, suggesting that the intercept interpretation in this model is meaningless.

To get a meaningful interpretation for the intercept in your third model, you could center the disp variable around its observed mean value in the data (presuming disp has an an approximately normal distribution), center the hp variable around its observed mean value in the data (presuming hp has an an approximately normal distribution), and then re-fit the model:

disp.cen <- mtcars$disp - mean(mtcars$disp)

hp.cen <- mtcars$hp - mean(mtcars$hp)

lm(mpg ~ disp.cen + hp.cen, data=mtcars))

In the re-fitted third model, the intercept will represent the mean value of mpg for all cars represented by the ones included in this data set which have a "typical" displacement (disp) and a "typical" horse power (hp). Here, a "typical" displacement means the average displacement observed in the data, whereas a typical horse power means the average horse power observed in the data.

Addendum

The word expected is synonimous with the word mean in this answer. Thus, the expected value of the variable mpg is the same as the mean (or average) value.

There are two types of mean values for the mpg variable - unconditional and conditional.

The unconditional mean of mpg refers to the mean value of mpg across all cars represented by the ones in the dataset, regardless of their other caracteristics (e.g., disp, hp). In other words, you would mix together all cars represented by the ones in your data - those with high disp and high hp, those with high disp and low hp, etc. - and compute their mean mpg value, which is an unconditional mean value (in the sense that it does NOT depend on other car characteristics).

The conditional mean of mpg refers to the mean value of mpg across those cars represented by the ones in the dataset which share one or more caracteristics. You could have:

  1. A conditional mean of mpg given disp;

  2. A conditional mean of mpg given hp;

  3. A conditional mean of mpg given disp and hp.

The conditional mean of mpg given disp refers to the mean value of mpg across all cars represented by the ones in your data set which share the same displacement (disp). Since disp can take multiple values, each of its values gives rise to a different conditional mean of mpg given disp. The model that describes how the conditional mean of mpg given disp varies as a function of the disp values is:

lm(mpg ~ disp, data = mtcars)

This model assumes that the conditional mean of mpg given disp is a linear function of disp.

The conditional mean of mpg given hp refers to the mean value of mpg across all cars represented by the ones in your data set which share the same horse power (hp). Since hp can take multiple values, each of its values gives rise to a different conditional mean of mpg given hp. The model that describes how the conditional mean of mpg given hp varies as a function of the hp values is:

lm(mpg ~ hp, data = mtcars)

This model assumes that the conditional mean of mpg given hp is a linear function of hp.

The conditional mean of mpg given disp and hp refers to the mean value of mpg across all cars represented by the ones in your data set which share the same displacement (disp) and the same horse power (hp). Since disp and hp can both take multiple values, each of their combination of values gives rise to a different conditional mean of mpg given disp and hp. The model that describes how the conditional mean of mpg given disp and hp varies as a function of the disp and hp values is:

lm(mpg ~ disp + hp, data = mtcars)

Of course, you could also have a model like:

lm(mpg ~ disp*hp, data = mtcars)

The first of the above models assumes that disp and hp have independent effects on mpg, while the second assumes that the effect of disp on mpg depends on the effect of hp and the other way around.

Isabella Ghement
  • 20.9k
  • 2
  • 37
  • 60