Multiple Linear Regressioin Part 1
Multiple Linear Regressioin Part 1
Lecture #7
Section 3.1: Motivation For Multiple Linear Regression
Course Name: Data Analysis – STAT3022
-Preview on Assignment 3
Recap on Simple Linear Regression
New Notation:
Sometimes we refer to a regression model in the following format: Y ~ 1 + X
For example: daughterHeight ~ 1 + motherHeight
Implications:
• For each observation: Y = 𝛽0 + 𝛽1𝑥 + 𝑒 What is “1”?
• Population model: 𝐸 𝑌 𝑋 = 𝑥 = 𝛽0 + 𝛽1𝑥 𝐸 𝑌𝑋=𝑥 = 𝛽0×1 + 𝛽1𝑥
• Fitted model: 𝑦* = 𝛽, 0 + 𝛽, 1 𝑥 𝑦* = 𝛽, 0 ×1 + 𝛽, 1 𝑥
Use the lm( ) function to obtain the fitted model in R -These two lines of code are
equivalent.
mod = lm(daughterHeight ~ motherHeight, data = Heights)
-R assumes that you want an
mod = lm(daughterHeight ~ 1 + motherHeight, data = Heights)
intercept regardless of
whether you have 1 in your
equation.
Number of Number of term(s)
explanatory/predictor
variable(s)
Model 3:
daughterHeight ~ 1 + motherHeight + 𝑚𝑜𝑡ℎ𝑒𝑟𝐻𝑒𝑖𝑔ℎ𝑡2
Why adding additional terms?
To provide a model with better fit (much larger 𝑅 2 ).
Adding the term (𝐸𝑥𝑝𝑒𝑟𝑖𝑒𝑛𝑐𝑒2) helps the model capture the curvature in the data.
Fitting po lyno mial regres s ion in R:
Example: Mo deling s alary from years of experience for professional workers .
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 34.720498 0.828724 41.90 <2e-16 ***
Experience 2.872275 0.095697 30.01 <2e-16 ***
I(Experience^2) -0.053316 0.002477 -21.53 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) 48.50593 1.08810 44.58 <2e-16 ***
Experience 0.88345 0.05158 17.13 <2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
• Price = the price (in $US) of dinner (including one drink & a tip)
• Food = customer rating of the food (out of 30)
• Décor = customer rating of the decoration (out of 30)
Model A:
𝑃𝑟𝑖𝑐𝑒 = −17.83 + 2.94𝐹𝑜𝑜𝑑.
𝑅 2 = 0.39
Coefficients:
Estimate Std. Error t value Pr(>|t|)
(Intercept) -24.5002 4.7230 -5.187 6.19e-07 ***
Food 1.6461 0.2615 6.294 2.68e-09 ***
Decor 1.8820 0.1919 9.810 < 2e-16 ***
---
Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Technical interpretation: When the food rating and the decoration rating are ,
the price of the dinner is -$24.5 on average.