Lecture 26 - Multiple Linear Regression

Penelope Pooler Eisenbies
MAS 261

2023-11-30

Housekeeping

  • Today’s plan 📋

    • Review of Simple Linear Regression (SLR) Concepts from Lecture 25

      • Interpreting Regression Model Output

      • Understanding the Hypotheses

      • Drawing conclusions

      • Answering estimation questions

    • Introduction to Multiple Linear Regression (MLR)

      • How to add variables to a model

      • Interpreting a model with more than one X variable

      • Examining MLR Model Output

      • Understanding hypotheses being tested

      • Answering estimation questions

Review: R and RStudio 🪄

  • Review: You have two options to facilitate your introduction to R and RStudio:

  • If you are comfortable with coding: Start with Option 1, but still sign up for Posit Cloud account.

    • We will use Posit Cloud for Quizzes.
  • If you are nervous about coding: Choose Option 2.

  • For both options: I can help with download/install issues during office hours.

  • What I do: I maintain a Posit Cloud account for helping students but I do most of my work on my laptop.

  • NOTE: We will use R and RStudio in class during MOST lectures

    • You can use either Posit Cloud or your laptop.

Upcoming Dates

  • Including today there are four more lectures

    • Four more opportunities to submit engagement questions

    • I rearranged the syllabus (slightly) to put today’s topic first.

  • HW 8 is posted and covers

    • Portfolio calculations

      • I will demo these calculations in class and create a video this weekend.
    • Simple Linear Regression

    • HW 8 is due on 12/6 (2 day grace period.)

  • There will, most likely, be one more short HW assignment

  • Final Exam is on 12/19/23

💥 Lecture 26 In-class Exercises - Q1 💥

Below is the model output for a regression model relating the size of the living area of a house to it’s selling price.

What is the estimated selling price of a 2000 sq. ft. house, based on this model?

Round your answer to a whole dollar amount.

(house_mod1 <- ols_regress(Price ~ Living_Area, data=real_estate))
                            Model Summary                              
----------------------------------------------------------------------
R                       0.772       RMSE                    45655.479 
R-Squared               0.596       Coef. Var                  27.670 
Adj. R-Squared          0.594       MSE                2084422772.677 
Pred R-Squared          0.579       MAE                     31692.288 
----------------------------------------------------------------------
 RMSE: Root Mean Square Error 
 MSE: Mean Square Error 
 MAE: Mean Absolute Error 

                                       ANOVA                                         
------------------------------------------------------------------------------------
                         Sum of                                                     
                        Squares         DF         Mean Square       F         Sig. 
------------------------------------------------------------------------------------
Regression     609852999259.857          1    609852999259.857    292.576    0.0000 
Residual       412715708990.143        198      2084422772.677                      
Total         1022568708250.000        199                                          
------------------------------------------------------------------------------------

                                       Parameter Estimates                                        
-------------------------------------------------------------------------------------------------
      model         Beta    Std. Error    Std. Beta      t        Sig         lower        upper 
-------------------------------------------------------------------------------------------------
(Intercept)    16505.199      9262.237                  1.782    0.076    -1760.095    34770.493 
Living_Area       82.588         4.828        0.772    17.105    0.000       73.066       92.110 
-------------------------------------------------------------------------------------------------

💥 Lecture 26 In-class Exercises - Q1 con’t 💥

Focus on the Parameter Estimates table to answer this question:

house_mod1$betas |> round(3)
(Intercept) Living_Area 
  16505.199      82.588 

Regression Output Interpretation in MAS 261

Only Requirements: Interpreting Parameter Estimates Beta (model coefficients) and Sig (P-values) columns

  • \(Est. Selling Price = 16505.199 + 82.588\times Living Area\)

Limitations of Simple Linear Regression

Simmple Linear Regression - One X variable

In this case, X is the size of the living area.

This model says that regardless of other factors

  • a 2500 sq. ft house has a selling price of 222975.

The model ignores number of bathrooms, age of house, etc.

These factors may also be helpful in explaining selling price.


  • Correlation between Living Area and Selling price is 0.77

  • This a is strong correlation, but maybe we can explain more of the variability in the data.

Simple Linear Regression vs. Multiple Linear Regression

Transitioning from SLR to MLR is Straightforward

  • In R and most software adding a variable to our model is as simple as addition.

  • The challenge is interpretation because we can no longer visualize the model.

  • There are 3-D visualization tools in R, BUT they are not always helpful.

  • Instead I recommend extending the SLR model output interpretation to the variables in the model.

  • One the next slide we’ll add number of bathrooms.

    • Spoiler: Number of bathrooms is a huge deal when buying a house.

MLR

(house_mod2 <- ols_regress(Price ~ Living_Area + Bathrooms, data=real_estate))
                            Model Summary                              
----------------------------------------------------------------------
R                       0.815       RMSE                    41726.448 
R-Squared               0.665       Coef. Var                  25.289 
Adj. R-Squared          0.661       MSE                1741096458.349 
Pred R-Squared          0.640       MAE                     30629.922 
----------------------------------------------------------------------
 RMSE: Root Mean Square Error 
 MSE: Mean Square Error 
 MAE: Mean Absolute Error 

                                       ANOVA                                         
------------------------------------------------------------------------------------
                         Sum of                                                     
                        Squares         DF         Mean Square       F         Sig. 
------------------------------------------------------------------------------------
Regression     679572705955.336          2    339786352977.668    195.157    0.0000 
Residual       342996002294.664        197      1741096458.349                      
Total         1022568708250.000        199                                          
------------------------------------------------------------------------------------

                                        Parameter Estimates                                         
---------------------------------------------------------------------------------------------------
      model          Beta    Std. Error    Std. Beta      t        Sig          lower        upper 
---------------------------------------------------------------------------------------------------
(Intercept)    -11553.295      9556.111                 -1.209    0.228    -30398.701     7292.110 
Living_Area        58.047         5.875        0.543     9.881    0.000        46.462       69.633 
  Bathrooms     38141.447      6027.411        0.348     6.328    0.000     26254.916    50027.977 
---------------------------------------------------------------------------------------------------

A closer look at the Parameter Estimates

Interpreting the new Model

Model: \[ Est. Selling Price = -11553.295 + 58.047\times Living Area + 38141.447 \times Bathrooms \]

Interpretation:

  • If number of bathrooms remains unchanged, each additional square foot is estimated to raise the selling price by about 58 dollars.

  • If living area remains unchanged, each additional bathroom will raise the estimated selling price by about 38 THOUSAND dollars.

💥 Lecture 26 In-class Exercises - Q2 💥

Based on this model, if a house is renovated to increase the square footage by 1000 square feet and two bathrooms are added, what would be estimated change in price?

Round your answer to a whole dollar amount.

Model: \[ Est. Selling Price = -11553.295 + 58.047\times Living Area + 38141.447 \times Bathrooms \]

To answer this question, exclude the intercept because we are only inteested in the change in price, not the price itself.

house_mod2$betas |> round(3)
(Intercept) Living_Area   Bathrooms 
 -11553.295      58.047   38141.447 

Adding ANOTHER Term to our MLR

next, we add age of the house to the model:

(house_mod3 <- ols_regress(Price ~ Living_Area + Bathrooms + House_Age, data=real_estate))
                            Model Summary                              
----------------------------------------------------------------------
R                       0.821       RMSE                    41279.100 
R-Squared               0.673       Coef. Var                  25.018 
Adj. R-Squared          0.668       MSE                1703964107.727 
Pred R-Squared          0.641       MAE                     30119.407 
----------------------------------------------------------------------
 RMSE: Root Mean Square Error 
 MSE: Mean Square Error 
 MAE: Mean Absolute Error 

                                       ANOVA                                         
------------------------------------------------------------------------------------
                         Sum of                                                     
                        Squares         DF         Mean Square       F         Sig. 
------------------------------------------------------------------------------------
Regression     688591743135.442          3    229530581045.147    134.704    0.0000 
Residual       333976965114.558        196      1703964107.727                      
Total         1022568708250.000        199                                          
------------------------------------------------------------------------------------

                                       Parameter Estimates                                         
--------------------------------------------------------------------------------------------------
      model         Beta    Std. Error    Std. Beta      t        Sig          lower        upper 
--------------------------------------------------------------------------------------------------
(Intercept)     5775.299     12087.330                  0.478    0.633    -18062.622    29613.220 
Living_Area       60.614         5.918        0.567    10.243    0.000        48.943       72.285 
  Bathrooms    30089.928      6913.944        0.274     4.352    0.000     16454.654    43725.201 
  House_Age     -235.721       102.458       -0.112    -2.301    0.022      -437.783      -33.658 
--------------------------------------------------------------------------------------------------

Examing the new model

Hopefully, the interpretation will seem redundant at this point…

The New Model

Model: \[ Est. Selling Price = 5775.299 + 60.614\times Living Area + 30089.928 \times Bathrooms - 235.721\times House Age \]

Interpretation:

  • If number of bathrooms and age of the house remain unchanged, each additional square foot is estimated to raise the selling price by about 61 dollars.

  • If living area and age of the house remain unchanged, each additional bathroom will raise the estimated selling price by about 30 THOUSAND dollars.

  • If living area and number of bathrooms remain unchanged, each additional year will LOWER the estimated selling price by about 236 dollars.

💥 Lecture 26 In-class Exercises - Q3 💥

What is the estimated price of a house that 2500 square feet with 4 bathrooms that is 20 years old?

Round your answer to a whole dollar amount.

Model: \[ Est. Selling Price = 5775.299 + 60.614\times Living Area + 30089.928 \times Bathrooms - 235.721\times House Age \]

house_mod3$betas |> round(3)
(Intercept) Living_Area   Bathrooms   House_Age 
   5775.299      60.614   30089.928    -235.721 

In this case, the calculation INCLUDES the intercept because we want to estimate the price of a house, not the chage in price.

Much more to Cover about MLR Models in BUA 345

This introduction to MLR is meant to be exactly that.

Ideally this gives you a better understanding of some the Parameter Estimates outut.

What we don’t cover until BUA 345:

  • Using the p-values and model fit statistics to decide between models

    • Which variables should we keep in the model?

    • How much information does each variable add to the model?

    • Are there interactions between the variables that should be added to the model?

  • In the modeling section of BUA 345:

    • Short review of SLR and MLR models and then continue with these topics.

    • More time spent on dagnostics and writing the model code.

Key Points from Today

  • MLR models are a logical and straightforward extension of SLR models

  • Visualizing MLR models isn’t feasible

  • Interpretation is similar, but not identical to MLR models.

    • As with SLR models, the model is only valid for the range of X values used to create it.

    • Today’s model would not apply to a 10000 square foot house with 8 bathrooms.

  • Regression model output includes hypothesis tests of each model coefficient.

    • For SLR and MLR, the hypothesis test of \(\beta_{i}\) is an indication of whther that variable is useful to the model.

    • In BUA 345, we will use these hypothesis tests and other measures of model fit to determine which variables to include in our models.

To submit an Engagement Question or Comment about material from Lecture 26: Submit by midnight today (day of lecture). Click on Link next to the under Lecture 26