data(women)
attach(women)
head(women)
##   height weight
## 1     58    115
## 2     59    117
## 3     60    120
## 4     61    123
## 5     62    126
## 6     63    129
wmod<-lm(weight~height, data = women)
summary(wmod)
## 
## Call:
## lm(formula = weight ~ height, data = women)
## 
## 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
confint(wmod,level = .9)
##                    5 %       95 %
## (Intercept) -98.030599 -77.002734
## height        3.288603   3.611397
newdata <- data.frame(height = 48)
weight.wmod <- lm(weight ~ height)
(predy <- predict(weight.wmod, newdata, interval="predict") )
##        fit     lwr      upr
## 1 78.08333 73.3104 82.85627
#predict the weight given that the height is 48in.
(confy <- predict(weight.wmod, newdata, interval="confidence") )
##        fit      lwr      upr
## 1 78.08333 74.62983 81.53684
confy %*% c(0, -1, 1) 
##       [,1]
## 1 6.907015
predy %*% c(0, -1, 1)
##       [,1]
## 1 9.545874
confy[1] == predy[1]
## [1] TRUE
#Both intervals are centered at the same place but the predict interval is wider than the confidence interval

weight <- rnorm(136.7, sd=15.49869)
height <- rnorm(65, sd=4.472136)
var.test(weight, height)
## 
##  F test to compare two variances
## 
## data:  weight and height
## F = 15.647, num df = 135, denom df = 64, p-value < 2.2e-16
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
##  10.07854 23.51869
## sample estimates:
## ratio of variances 
##           15.64706
#This is the F test to compare two vairances. There is a strong relationship between the weight and height