class: center, middle, inverse, title-slide # Multiple Linear Regression ### Dr. Dogucu --- layout: true <div class="my-header"></div> <div class="my-footer"> Copyright © <a href="https://mdogucu.ics.uci.edu">Dr. Mine Dogucu</a>. <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/">CC BY-NC-SA 4.0</a></div> --- ## Multiple Linear Regression So far, we have been working with only one predictor (gestation or smoke). Because there was only one predictor in each model, we call these models single linear regression models. -- Both of these predictors are significant in explaining the variation in birth weight. We can simultanously consider them in a single model, a multiple linear regression model. -- `$$y_i = \beta_0 + \beta_1x_{1i} +\beta_2x_{2i} +\epsilon_i$$` -- `$$y_i = \beta_0 + \beta_1x_{1i} +\beta_2x_{2i} +.... + \beta_kx_{ki} +\epsilon_i$$` --- #### Data `babies` ``` ## Rows: 1,236 ## Columns: 8 ## $ case <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, … ## $ bwt <int> 120, 113, 128, 123, 108, 136, 138, 132, 120, 143, 140, 144,… ## $ gestation <int> 284, 282, 279, NA, 282, 286, 244, 245, 289, 299, 351, 282, … ## $ parity <int> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,… ## $ age <int> 27, 33, 28, 36, 23, 25, 33, 23, 25, 30, 27, 32, 23, 36, 30,… ## $ height <int> 62, 64, 64, 69, 67, 62, 62, 65, 62, 66, 68, 64, 63, 61, 63,… ## $ weight <int> 100, 135, 115, 190, 125, 93, 178, 140, 125, 136, 120, 124, … ## $ smoke <int> 0, 0, 1, 0, 1, 0, 0, 0, 0, 1, 0, 1, 1, 1, 0, 0, 1, 1, 0, 1,… ``` --- class: middle <div align = "center"> | y | Response | Birth weight | Numeric | |---|-------------|-----------------|---------| | `\(x_1\)` | Explanatory | Gestation | Numeric | | `\(x_2\)` | Explanatory | Smoke | Binary | --- class: middle center `$$bwt_i = \beta_0 + \beta_1gestation_{i} +\beta_2smoke_{i} +\epsilon_i$$` -- `$$\hat{bwt}_i = \beta_0 + \beta_1gestation_{i} +\beta_2smoke_{i}$$` --- ```r model_gs <- lm(bwt ~ gestation + smoke, data = babies) tidy(model_gs) ``` ``` ## # A tibble: 3 x 5 ## term estimate std.error statistic p.value ## <chr> <dbl> <dbl> <dbl> <dbl> ## 1 (Intercept) -0.932 8.15 -0.114 9.09e- 1 ## 2 gestation 0.443 0.0290 15.3 3.16e-48 ## 3 smoke -8.09 0.953 -8.49 5.96e-17 ``` -- **Non-smoker mother & 300 days of gestation** `\(\hat bwt_i = -0.932 + 0.443 \times 300 - 8.09\times 0=\)` 131.968 **Smoker mother & 300 days of gestation** `\(\hat bwt_i = -0.932 + 0.443 \times 300 - 8.09\times 1=\)` 123.878