Women

Use the women data (built into R); in particular, use the women’s weight as the response and the height as the predictor.

data(women)
attach(women)
names(women)
## [1] "height" "weight"
women
##    height weight
## 1      58    115
## 2      59    117
## 3      60    120
## 4      61    123
## 5      62    126
## 6      63    129
## 7      64    132
## 8      65    135
## 9      66    139
## 10     67    142
## 11     68    146
## 12     69    150
## 13     70    154
## 14     71    159
## 15     72    164
summary(women)
##      height         weight     
##  Min.   :58.0   Min.   :115.0  
##  1st Qu.:61.5   1st Qu.:124.5  
##  Median :65.0   Median :135.0  
##  Mean   :65.0   Mean   :136.7  
##  3rd Qu.:68.5   3rd Qu.:148.0  
##  Max.   :72.0   Max.   :164.0

These call the data and shows the data that is found in women, which is the height and weight of 15 women.

Including Plots

plot(height,weight)

This calls a plot of the women’s height and weight which has a upward, linear trend.

plot(height, weight, ylab = "Weight in pounds",
      xlab = "Height in inches", 
      main = "Height and Weight of Women")
abline(-87.52,3.45)

This adds labels to the graph and makes it look nicer and it shows that the graph isn’t heteroscedasticity

Mod

mymod <- lm(weight ~ height)
mymod
## 
## Call:
## lm(formula = weight ~ height)
## 
## Coefficients:
## (Intercept)       height  
##      -87.52         3.45
summary(mymod)
## 
## Call:
## lm(formula = weight ~ height)
## 
## Residuals:
##     Min      1Q  Median      3Q     Max 
## -1.7333 -1.1333 -0.3833  0.7417  3.1167 
## 
## Coefficients:
##              Estimate Std. Error t value Pr(>|t|)    
## (Intercept) -87.51667    5.93694  -14.74 1.71e-09 ***
## height        3.45000    0.09114   37.85 1.09e-14 ***
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
## 
## Residual standard error: 1.525 on 13 degrees of freedom
## Multiple R-squared:  0.991,  Adjusted R-squared:  0.9903 
## F-statistic:  1433 on 1 and 13 DF,  p-value: 1.091e-14

This tells the intercept of the graph, the slope, and the residual standard error.

residual

myresids <- mymod$residuals
 myresids
##           1           2           3           4           5           6 
##  2.41666667  0.96666667  0.51666667  0.06666667 -0.38333333 -0.83333333 
##           7           8           9          10          11          12 
## -1.28333333 -1.73333333 -1.18333333 -1.63333333 -1.08333333 -0.53333333 
##          13          14          15 
##  0.01666667  1.56666667  3.11666667
 hist(myresids)

  qqnorm(myresids)
 qqline(myresids) 

The qqline shows that the height and weight of women is normally dist.

Mean sq error

sqrt(sum((mymod$residuals)^2)/48)
## [1] 0.7936379