date()
## [1] "Sun Dec 09 22:49:10 2012"
Due Date: December 7, 2012, 2pm
Total Points: 30; Points are given in parentheses.
(1) Use the FLprecip.txt file on my website http://myweb.fsu.edu/jelsner/ and peform a t-test to determine if Florida is significantly drier during May compared with August. (10)
FLp = read.table("http://myweb.fsu.edu/jelsner/FLprecip.txt", header = TRUE)
head(FLp)
## Year Jan Feb Mar Apr May Jun Jul Aug Sep Oct
## 1 1895 3.277 3.241 2.499 4.530 4.252 4.500 7.450 6.103 4.669 3.091
## 2 1896 3.928 3.020 2.570 0.498 2.700 11.228 8.217 5.892 4.352 2.959
## 3 1897 1.839 6.000 2.125 4.390 2.279 5.221 7.212 6.831 11.144 4.101
## 4 1898 0.704 2.009 1.259 1.320 1.509 3.292 8.947 13.090 5.231 5.877
## 5 1899 4.523 5.921 1.898 3.398 1.110 5.803 9.264 6.712 5.132 5.882
## 6 1900 3.207 4.369 6.800 4.317 3.891 9.993 7.501 4.492 4.930 5.230
## Nov Dec
## 1 2.649 1.586
## 2 3.516 2.071
## 3 1.749 2.680
## 4 2.190 3.891
## 5 0.751 1.939
## 6 1.221 4.290
t.test(FLp$May, FLp$Aug)
##
## Welch Two Sample t-test
##
## data: FLp$May and FLp$Aug
## t = -12.21, df = 219.2, p-value < 2.2e-16
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -3.882 -2.802
## sample estimates:
## mean of x mean of y
## 3.857 7.199
(2) Suppose 15 randomly chosen people of varying ages are tested for maximum heart rate and the following data are found.
Age = c(18, 23, 25, 35, 65, 54, 34, 56, 72, 19, 23, 42, 18, 39, 37)
HR = c(202, 186, 187, 180, 156, 169, 174, 172, 153, 199, 193, 174, 198, 183,
178)
The age is in years and the heart rate is in beats per minute.
(a) Determine the intercept and slope of a regression model of heart rate on age. (10)
require(ggplot2)
## Loading required package: ggplot2
p = ggplot(data.frame(Age, HR), aes(Age, HR)) + geom_point(size = 4)
p = p + geom_smooth(method = lm, se = FALSE, col = "red")
p
model = lm(HR ~ Age)
model
##
## Call:
## lm(formula = HR ~ Age)
##
## Coefficients:
## (Intercept) Age
## 210.048 -0.798
(b) Predict the average heart rate of a 50-year old. (10)
predict(model, data.frame(Age = 50))
## 1
## 170.2
the average heart rate of a 50 yr old is 170.2