Q1-5

  1. Nonparametric tests do not assume the distribution of the parameter. Therefore, there are less assumptions asked.

  2. Advantage: There is barely any assumption required to use the test

Disadvantage: It does not take into account the magnitude of the data

  1. Wilcoxon signed-rank test uses rank to use the magnitude of the data

  2. Wilcoxon rank sum test does not assume normality of the data while t-test does

  3. Advantage: It handles the outliers well and allows to get confidence interval easily

Disadvantage: It may overestimate the difference in data, makes it less precise rejection region due to discontinuity

Q6

(a) Wilcoxon Signed-Rank Test for median = 0

cf <- c(1153,1132,1165,1460,1634,1493,1358,
        1453,1185,1824,1793,1930,2075)
healthy <- c( 996,1080,1182,1452,1162,1619,1140,
             1123,1113,1463,1632,1614,1836)
wilcoxsign_test(cf ~ healthy, distribution = exact())
## 
##  Exact Wilcoxon-Pratt Signed-Rank Test
## 
## data:  y by x (pos, neg) 
##   stratified by block
## Z = 2.6906, p-value = 0.004639
## alternative hypothesis: true mu is not equal to 0

The p-value is less than 0.01. Therefore, we reject the null hypothesis at 99% confidence level, and we have evidence that the true median difference is not 0.

(b) Sign Test for median = 0

sign_test(cf ~ healthy, distribution = exact())
## 
##  Exact Sign Test
## 
## data:  y by x (pos, neg) 
##   stratified by block
## Z = 2.4962, p-value = 0.02246
## alternative hypothesis: true mu is not equal to 0

The p-value is around 0.02. Therefore we fail to reject at 99% confidence level, but we do reject the null at 95% confidence level. This means that the Wilcoxon Signed-Rank test showed higher confidence level than sign test.

Q7

(a) Sign Test for median = 0

time1 <- c(62,35,38,80,48,48,68,26,48,27,43,67,52,88)
time2 <- c(46,42,40,42,36,46,45,40,42,40,46,31,44,48)
sign_test(time1 ~ time2, distribution = exact())
## 
##  Exact Sign Test
## 
## data:  y by x (pos, neg) 
##   stratified by block
## Z = 1.069, p-value = 0.424
## alternative hypothesis: true mu is not equal to 0

The p-value is 0.424, therefore we fail to reject the null and we have evidence that the true median difference is 0.

(b) Wilcoxon Signed-Rank Test for median = 0

wilcoxsign_test(time1 ~ time2, distribution = exact())
## 
##  Exact Wilcoxon-Pratt Signed-Rank Test
## 
## data:  y by x (pos, neg) 
##   stratified by block
## Z = 1.6326, p-value = 0.1075
## alternative hypothesis: true mu is not equal to 0

The p-value is around 0.1, which is less than the sign test result. We have larger rejection region, but still reject the null with significance level more than 90%.

(c) Comparison of a and b

We have the same result, however the Wilcoxon Signed Rank test showed larger rejection region.

Q8

(a) Median = 0

air <- c(0.82,0.86,1.86,1.64,12.57,1.56,1.28,1.08,4.29,1.37,
         14.68,3.64,3.89,0.58,9.50,0.93,0.49,31.04,1.66)
so2 <- c(0.72,1.05,1.40,2.30,13.49,0.62,2.41,2.32,8.19,6.33,
         19.88,8.87,9.25,6.59,2.17,9.93,13.44,16.25,19.89)
wilcoxsign_test(air ~ so2, distribution = exact())
## 
##  Exact Wilcoxon-Pratt Signed-Rank Test
## 
## data:  y by x (pos, neg) 
##   stratified by block
## Z = -2.0926, p-value = 0.03607
## alternative hypothesis: true mu is not equal to 0

Since this is paired data, we use Wilcoxon Signed-Rank test. The p-value is little less than 0.04, therefore we reject the null at 95% confidence level and we have evidence that the true median difference is not 0.

(b) paired t-test

qqnorm(air - so2)

To be able to use paired t-test, the data needs to be roughly normal. Looking at the difference’s normal quantile plot, we can assume that the data may be slightly off from being normal. Just to be more accurate, it is more appropriate to use nonparametric methods for this case.

Q9

(a)

Using the table for sample size (6, 6), the p-value is 0.01.

(b)

We use the minimum of the absolute values of those two sums. Therefore, our test statistic is 6. The alpha = 0.05 has critical value of 5 and 0.10 has critical value of 7. Therefore, the p-value is in between 0.05 and 0.10.