A civil engineer is interested in determining whether four different methods of estimating flood flow frequency produce equivalent estimates of peak discharge when applied to the same watershed. Each procedure is used six times on the watershed, and the resulting discharge data (in cubic feet per second) are shown below.
Below is the data set and beyond that is the set of basic descriptive statistics:
\[ y_{ij}= \mu +\tau_{ij} +\varepsilon_{ij} \]
\[ H_{0} : \mu_{1} = \mu_{2} = \mu_{3} = \mu_{4} = \mu \]
\[ H_{a} : At\ least\ one\ mean\ differs\ from\ mu \]
pop1<-c(0.34, 0.12, 1.23, 0.70, 1.75, 0.12)
pop2<-c(0.91, 2.94, 2.14, 2.36, 2.86, 4.55)
pop3<-c(6.31, 8.37, 9.75, 6.09, 9.82, 7.24)
pop4<-c(17.15, 11.82, 10.97, 17.20, 14.35, 16.82)
pop<-c(pop1, pop2, pop3, pop4)
qqnorm(pop1)
qqnorm(pop2)
qqnorm(pop3)
qqnorm(pop4)
x<-c(rep(1,6),rep(2,6),rep(3,6),rep(4,6))
Dat<-data.frame(x,pop)
Dat$x <- as.factor(Dat$x)
boxplot(pop~x,xlab="Estimation Method",ylab="observation",main="Boxplot of Observations")
There is too little data to really be sure if the data is normally distributed and with constant variance. The normal plot shows approximately normal but this has too few data points to be powerful. The Box plot shows unequal variance but this is not powerful because of the limited samples.
?kruskal.test
kruskal.test(pop~x,data=Dat)
##
## Kruskal-Wallis rank sum test
##
## data: pop by x
## Kruskal-Wallis chi-squared = 21.156, df = 3, p-value = 9.771e-05
We reject the null hypothesis that all of the means are the same because our p value is .0000977 which is smaller then .05. We are very confident that at least one mean differs from the others.
library(MASS)
boxcox(pop~x)
Looking at the plot generated by the boxcox test, it is clear that the data needs to be transformed by a power of .5.
lambda=.5 # only if 1 is not in CI on lambda
pop1<-pop^(lambda) # if lambda is not zero
boxcox(pop1~x)
Dat$pop<-pop1
In the graph generated by the transformed data boxcox graph, it is clear that 1 is in the 95% confidence interval. This indicates that we can go ahead and do a parametric test on the data. We will now perform an ANOVA test on the data to compare the means of the different populations.
?aov
model<-aov(pop~x, data=Dat)
summary(model)
## Df Sum Sq Mean Sq F value Pr(>F)
## x 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
plot(model)
This result again shows that we reject the null hypothesis and we can say that the means of the populations are not all equal. The variance is more stable in the transformed data.
Code:
pop1<-c(0.34, 0.12, 1.23, 0.70, 1.75, 0.12)
pop2<-c(0.91, 2.94, 2.14, 2.36, 2.86, 4.55)
pop3<-c(6.31, 8.37, 9.75, 6.09, 9.82, 7.24)
pop4<-c(17.15, 11.82, 10.97, 17.20, 14.35, 16.82)
pop<-c(pop1, pop2, pop3, pop4)
qqnorm(pop1)
qqnorm(pop2)
qqnorm(pop3)
qqnorm(pop4)
x<-c(rep(1,6),rep(2,6),rep(3,6),rep(4,6))
Dat<-data.frame(x,pop)
Dat$x <- as.factor(Dat$x)
boxplot(pop~x,xlab="Estimation Method",ylab="observation",main="Boxplot of Observations")
?kruskal.test
kruskal.test(pop~x,data=Dat)
##
## Kruskal-Wallis rank sum test
##
## data: pop by x
## Kruskal-Wallis chi-squared = 21.156, df = 3, p-value = 9.771e-05
library(MASS)
boxcox(pop~x)
lambda=.5 # only if 1 is not in CI on lambda
pop1<-pop^(lambda) # if lambda is not zero
boxcox(pop1~x)
Dat$pop<-pop1
?aov
model<-aov(pop~x, data=Dat)
summary(model)
## Df Sum Sq Mean Sq F value Pr(>F)
## x 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
plot(model)