## Solutions to exercises ### PART 1 ### # Loading data days = scan("pr0220.txt") # (a), (b), (c) # One sided hypothesis - we can assume the average is smaller than 120 # and try to reject this # H0: mu <= 120 # H1: mu > 120 t.test(days,mu=120,conf.level=0.99,alternative="greater") # ignore the confidence interval here, it is not the one we are looking for # (d) t.test(days,mu=120,conf.level=0.99) # here we have the right confidence interval # We clean up rm(list=ls()) ### PART 2 ### # Data values = scan("pr0225.txt") # The order of data is with alternating treatments # Here is a way to extract the two treatments: x = values[c(1, 3, 5, 7, 9, 11, 13, 15, 17, 19)] y = values[seq(2, 20, 2)] # A bit more sophisticated! # We do the tests var.test(x, y) # p=0.97, accept (suspiciously high!) t.test(x, y, var.equal=TRUE) # p=0.96, accept (the same!) # These high p-values are "too good to be true". I think that this # experiment has never really been made, only in Montgomery's mind! # Now solution to Question (c): # Normality assumed, but not critical for t-tests. Due to the central # limit theorem, means of ten closer to normality than individual data # Anyhow, let's do the normality check: qqnorm(x); qqline(x, col="green") # Looks tolerable qqnorm(y); qqline(y, col="green") # Looks nice # Cleaning rm(list=ls())