Solutions to Day 3 Homework

1. Read Prof. Fowler's notes, pages 13-18.

2. Do exercises 20, 23, 25, and 26 in Prof. Fowler's notes.

Exc. 20 part 1

Alpha = c(0.1, 0.025, 0.01, 0.005)
CutPts = qnorm(1 - Alpha, mean = 0, sd = 1)
print(CutPts)
## [1] 1.282 1.960 2.326 2.576

Exc. 20 part 2

for (d in seq(from = 1, to = 801, by = 100)) {
    print(qt(1 - Alpha, df = d))
}
## [1]  3.078 12.706 31.821 63.657
## [1] 1.290 1.984 2.364 2.625
## [1] 1.286 1.972 2.345 2.601
## [1] 1.284 1.968 2.339 2.592
## [1] 1.284 1.966 2.336 2.588
## [1] 1.283 1.965 2.334 2.586
## [1] 1.283 1.964 2.333 2.584
## [1] 1.283 1.963 2.332 2.583
## [1] 1.283 1.963 2.331 2.582
print("converging to:")
## [1] "converging to:"
print(CutPts)
## [1] 1.282 1.960 2.326 2.576

Exc. 23

x = c(1, 4, 2, 5, 6, 3, 4, 3)
t.test(x, conf.level = 0.95)
## 
##  One Sample t-test
## 
## data:  x 
## t = 6.173, df = 7, p-value = 0.0004569
## alternative hypothesis: true mean is not equal to 0 
## 95 percent confidence interval:
##  2.159 4.841 
## sample estimates:
## mean of x 
##       3.5
# CI is (2.16, 4.84)

Exc. 25

setwd("/Users/traves/Dropbox/SM339")
Michelson <- read.csv("Michelson.csv")
summary(Michelson)
##       Date     Image     Temperature      Velocity     Time   
##  13-Jun :10   fair:39   Min.   :58.0   Min.   :3e+05   am:37  
##  14-Jun :10   good:45   1st Qu.:72.0   1st Qu.:3e+05   pm:62  
##  20-Jun :10   poor:15   Median :77.0   Median :3e+05          
##  21-Jun :10             Mean   :76.4   Mean   :3e+05          
##  17-Jun : 8             3rd Qu.:83.5   3rd Qu.:3e+05          
##  18-Jun : 6             Max.   :90.0   Max.   :3e+05          
##  (Other):45
t.test(Michelson$Velocity, conf.level = 0.95)
## 
##  One Sample t-test
## 
## data:  Michelson$Velocity 
## t = 36211, df = 98, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 0 
## 95 percent confidence interval:
##  299834 299867 
## sample estimates:
## mean of x 
##    299851

A 95% CI for the speed of light is (299834,299867)

Michelson's estimate was (299802,299904) – a wider CI.

Exc. 26

HumanTemp <- read.csv("HumanTemp.csv")
summary(HumanTemp)
##       Temp           Sex         Pulse     
##  Min.   : 96.3   female:65   Min.   :57.0  
##  1st Qu.: 97.8   male  :65   1st Qu.:69.0  
##  Median : 98.3               Median :74.0  
##  Mean   : 98.2               Mean   :73.8  
##  3rd Qu.: 98.7               3rd Qu.:79.0  
##  Max.   :100.8               Max.   :89.0
t.test(HumanTemp$Temp, conf.level = 0.95)
## 
##  One Sample t-test
## 
## data:  HumanTemp$Temp 
## t = 1528, df = 129, p-value < 2.2e-16
## alternative hypothesis: true mean is not equal to 0 
## 95 percent confidence interval:
##  98.12 98.38 
## sample estimates:
## mean of x 
##     98.25

A 95% CI for Temperature is (98.1,98.4) The usual “average temperature” of 98.4 probably describes the upper level of normal temperatures – above that number suggests that something may be wrong with the patient.

3. [Walpole, Myers and Myers, Exc. 12 on p. 236] A manufacturing firm wonders how long the batteries used in their electronic games will last. They test 16 batteries and find that the sample mean is xbar = 27.5 hours and sample standard deviation is s = 5 hours. Find a 95% confidence interval for the true mean of the life of their batteries.

n = 16
xbar = 27.5
s = 5
CI.level = 0.95
tstar = qt(1 - (1 - CI.level)/2, df = n - 1)
CI.low = xbar - tstar * s/sqrt(n)
CI.high = xbar + tstar * s/sqrt(n)
print(c(CI.low, CI.high))
## [1] 24.84 30.16

4. [Larsen and Marx, Exc. 5.3.9] In 1927, the year he hit 60 home runs, Babe Ruth batted .356, having collected 192 hits in 540 official at-bats (see reference 145 in Larsen and Marx). Assume that the sample standard deviation of the 0/1 variable measuring his hits has standard deviation 0.47. Based on his performance that season, construct a 95% confidence interval for Ruth's probability of getting a hit in a future at-bat.

n = 540
obs = 0.356
st.dev = 0.47
lower.CI = obs - qt(1 - 0.025, df = n - 1) * st.dev/sqrt(n)
upper.CI = obs + qt(1 - 0.025, df = n - 1) * st.dev/sqrt(n)
print(c(lower.CI, upper.CI))
## [1] 0.3163 0.3957

A 95% CI for Babe Ruth's true probability of a hit is (0.316, 0.396)