Question 3.20

#NULL HYPOTHESIS:H0:MU1=MU2=MU3=MU4=MU
#ALTERNATIVE HYPOTHESIS:Atleast one MUi differs where i={1,2,3,4}


#importing the given data

RL10<-c(1530, 1530, 1440)
RL15<-c(1610, 1650, 1500)
RL20<-c(1560, 1730, 1530)
RL25<-c(1500, 1490, 1510)


R<-rbind(RL10,RL15,RL20,RL25)
#calculating the grand average and mean 
GAvg<-c(mean(R))

R1<-mean(RL10)
R2<-mean(RL15)
R3<-mean(RL20)
R4<-mean(RL25)
#calculating SSE, SSTr, MSTr, F Statistic and Critical Regions

SSEa<-(1530-R1)^2+(1530-R1)^2+(1440-R1)^2
SSEb<-(1610-R2)^2+(1650-R2)^2+(1500-R2)^2
SSEc<-(1560-R3)^2+(1730-R3)^2+(1530-R3)^2
SSEd<-(1500-R4)^2+(1490-R4)^2+(1510-R4)^2

SSE<-SSEa+SSEb+SSEc+SSEd

MSE <- SSE / (8)

str(MSE)
##  num 5117
SSTr <- 3*((R1 - GAvg)^2 + (R2 - GAvg)^2 + (R3 - GAvg)^2 + (R4 - GAvg)^2)

str(SSTr)
##  num 28633
MSTr <- SSTr / (3)

str(MSTr)
##  num 9544
SST <- SSE + SSTr

str(SST)
##  num 69567
Statistic <- MSTr / MSE

str(Statistic)
##  num 1.87
qf(0.95, 3, 8)
## [1] 4.066181
#Answer a

#Therefore we have F statistic value (1.87) is less than critical value (4.066)
#So, we fail to reject H0 and by this we can conclude that there is no difference in compressive strength due to the rodding level

#Answer b

#By the above values in statistics in a F distribution calculator, we found the P value which is (0.2138)