04/13/2025

Topic: Relationship between woman’s height and weight using simple linear regression

data(women)
tail(women)
##    height weight
## 10     67    142
## 11     68    146
## 12     69    150
## 13     70    154
## 14     71    159
## 15     72    164
  • Dataset of avg height and weight for American women

Women avg height & weight plot (ggplot)

Women avg height & weight trend (plotly)

Regression Line Added To Trend Plot

Residuals (ggplot)

Regression Equation

simple linear equation formula:

\[ \hat{y} = \beta_0 + \beta_1 x \]

\(\hat{y}\) is the estimated weight based on height
\(x\) is the height of the woman
\(\beta_0\) is the estimated weight (intercept) when height is 0
\(\beta_1\) is how much weight (lbs) increases for each extra inch of height

Estimating the slope

estimating the slope of a regression line

\[ \hat{\beta}_1 = \frac{\sum (x_i - \bar{x})(y_i - \bar{y})}{\sum (x_i - \bar{x})^2} \]

R code for trend plot with regression line (slide 5)

ggplot(women, aes(x=height,y=weight))+geom_point(color="purple")+
  geom_smooth(method = "lm", se = FALSE, color = "red")+
  labs(title = "Height vs Weight, and Regression Line",
       x = "Height",
       y = "Weight")