Q1.

Part (a)

Linear effects equation \[Y_{ij} = \mu + \tau_{i} + \epsilon_{ij}\] Hypothesis: \[H_0:\ \mu_1 = \mu_2 = \mu_3 = \mu_4 \]\[ H_1:\ \text{At least one } \mu_i \text{ differs from the others}\]

Part (b)

library(tidyr)
library(dplyr)
data1 <- c(0.34,0.12,1.23,0.70,1.75,0.12)
data2 <- c(0.91,2.94,2.14,2.36,2.86,4.55)
data3 <- c(6.31,8.37,9.75,6.09,9.82,7.24)
data4 <- c(17.15,11.82,10.97,17.20,14.35,16.82)
data<-data.frame(data1,data2,data3,data4)
datapivot<-pivot_longer(data,c(data1,data2,data3,data4))
dataplot<-c(data1,data2,data3,data4)
x<-factor(c(rep(1,6),rep(2,6),rep(3,6),rep(4,6)))
meanx<-c(rep(mean(data1),6),rep(mean(data2),6),rep(mean(data3),6),rep(mean(data4),6))
res<-dataplot-meanx
boxplot(dataplot~x,xlab="Estimation Method",ylab="Observation",main="Boxplot of Observations")

qqnorm(res, main = "QQNormal Plot of Residuals")
qqline(res)

plot(meanx,res,xlab="Population Average",ylab="Residual",main="Constant Variance wrt Population Means")

The assumption of normality is reasonable. However, the constant variance assumption does not appear to be satisfied.

Part (c)

aov.model<-aov(value~name,data=datapivot)
summary(aov.model)
##             Df Sum Sq Mean Sq F value Pr(>F)    
## name         3  708.7   236.2   76.29  4e-11 ***
## Residuals   20   61.9     3.1                   
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Since the p value of 4e-11 is less 0.05, therefore reject H0. There is evidence that at least one estimation method has a different mean discharge estimate.

plot(aov.model)

The residuals indicates that the variance is not constant.

Part (d)

library(MASS)
boxcox(dataplot~x)

Based on the Box-Cox. λ is approximately 0.5.

lambda<-0.5
dataplot.trans<-dataplot^lambda
boxcox(dataplot.trans~x)

The above plot now shows a value of lambda close to 1, indicating the transformation was effective.

boxplot(dataplot.trans~x,
        xlab="Estimation Method",
        ylab="Transformed Observation",
        main="Boxplot after Square-Root Transformation")

datapivot$transvalue<-sqrt(datapivot$value)
aov.trans<-aov(transvalue~name,data=datapivot)
summary(aov.trans)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## name         3  32.69  10.898   81.17 2.27e-11 ***
## Residuals   20   2.69   0.134                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Since the p value of 2.27e-11 is less 0.05, therefore reject H0. There is evidence that at least one estimation method has a different mean discharge estimate.

Part (e)

kruskal.test(value~name,data=datapivot)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  value by name
## Kruskal-Wallis chi-squared = 21.156, df = 3, p-value = 9.771e-05

Since the p value of 9.771e-05 is less 0.05, therefore reject H0. There is evidence that at least one estimation method has a different mean discharge estimate.