Q1 (a)

Data Import

t6q1 <- read.table("C:/Users/Wei Hao/Desktop/ST2137/Tutorials/Data/machine.txt", header=TRUE)
attach(t6q1)

Relabelling Columns

old <- strength[machine=="O"]
new <- strength[machine=="N"]

QQ Plots

qqnorm(old)

qqnorm(new)

Test If Variances Are Equal

var.test(new,old)
## 
##  F test to compare two variances
## 
## data:  new and old
## F = 0.79576, num df = 49, denom df = 49, p-value = 0.4268
## alternative hypothesis: true ratio of variances is not equal to 1
## 95 percent confidence interval:
##  0.4515745 1.4022782
## sample estimates:
## ratio of variances 
##          0.7957595

We need to check the equal variance assumption to decide which t-test to use. According to the F-test, the p-value is \(0.4268\) so we conclude that the equal variance assumption holds.

t-test

t.test(new, old, mu=0, alternative="greater", var.equal=TRUE)
## 
##  Two Sample t-test
## 
## data:  new and old
## t = 3.9304, df = 98, p-value = 7.905e-05
## alternative hypothesis: true difference in means is greater than 0
## 95 percent confidence interval:
##  4.460726      Inf
## sample estimates:
## mean of x mean of y 
##    71.972    64.248

Since we are testing for \(H_0 :\mu_N - \mu_O = 0\) against \(H_q: \mu_N - \mu_O > 0\), and that \(t_{obs} = 3.93 > t_0.05 (98) = 1.66\) or p-value \(=7.905 \times 10^{-5}\), we reject \(H_0\).

Q1(b)

We made the assumption that the variances are equal. As above, we have shown that we did not reject the null hypothesis where the variances are equal.

To check the normality assumption, we employ the Kolmogorov-Smirnov test and look at the QQ plots as well. The results below show that this is a reasonable assumption.

ks.test(old,"pnorm",mean(old),sd(old))
## Warning in ks.test(old, "pnorm", mean(old), sd(old)): ties should not be
## present for the Kolmogorov-Smirnov test
## 
##  One-sample Kolmogorov-Smirnov test
## 
## data:  old
## D = 0.10157, p-value = 0.6808
## alternative hypothesis: two-sided
ks.test(new,"pnorm",mean(new),sd(new))
## Warning in ks.test(new, "pnorm", mean(new), sd(new)): ties should not be
## present for the Kolmogorov-Smirnov test
## 
##  One-sample Kolmogorov-Smirnov test
## 
## data:  new
## D = 0.11769, p-value = 0.4928
## alternative hypothesis: two-sided

QQ Plots

par(mfrow=c(2,1))
qqnorm(old,main="QQ Plot for Old machine")
qqline(old,lty=2)
qqnorm(new,main="QQ Plot for New machine")
qqline(new,lty=2)

par(mfrow=c(1,1))