library(tidyverse)
library(ggplot2)
library(MASS)
library(mfp)
data("birthwt")
data("Pima.tr")
Platelet<- read.table("data/Platelet.txt", header=T, sep="")
data(bodyfat, package="mfp")
saltBP <- read.table(file="data/saltBP.txt", header=T, sep="")

We can use the lm() function to fit a multiple linear regression model. We separate the explanatory variables with plus signs.

multReg <- lm(siri ~ abdomen + weight , data=bodyfat)
summary(multReg)
## 
## Call:
## lm(formula = siri ~ abdomen + weight, data = bodyfat)
## 
## Residuals:
##      Min       1Q   Median       3Q      Max 
## -11.6459  -3.2071  -0.0299   3.1664  10.5064 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -45.95237    2.60501 -17.640  < 2e-16 ***
## abdomen       0.98950    0.05672  17.447  < 2e-16 ***
## weight       -0.14800    0.02081  -7.112 1.21e-11 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 4.456 on 249 degrees of freedom
## Multiple R-squared:  0.7188, Adjusted R-squared:  0.7165 
## F-statistic: 318.2 on 2 and 249 DF,  p-value: < 2.2e-16

Activity 1

  • We would like to predict a baby’s birthweight ({bwt}) using both mother’s weight at last menstrual period ({lwt}) and her smoking status ({smoke}).

  • Interpret the estimates of regression coefficients and comment on their statistical significance.

  • Find the 95% confidence interval for regression coefficients.

  • If mother’s weight at last menstrual period is 170 pounds and she was smoking during her pregnancy, what would be your estimate for the birthweight of her baby?

Activity 2

We want to examine how gender and heart rate might be associated with body temperature.

  • Use the ``BodyTemperature.txt’’ data set to build a multiple linear regression model for body temperature using heart rate and gender as predictors.
  • How much \(R^{2}\) increased compared the above simple linear regression model.
  • Explain the estimates of regression coefficients in plain language.
  • Find the 95% confidence intervals for regression coefficients.
  • If a woman’s heart rate is 75, what would be your estimate of her body temperature? What would be your estimate of body temperature for a man whose heart rate is 75.
  • Relax the additivity assumption and include the interaction term between gender and heart rate.