Execise 1

Use an interaction plot to display the Treatment:Concentration interaction.

crack.data <- read.table(header=TRUE, text="
Roadway cracks  Treatment   Concentration
      1   37      NaCl         Low
      1   49      NaCl         High
      1   43      CaCl         Low
      1   47      CaCl         High
      1   27      Sand         Low
      1   33      Sand         High
      2   39      NaCl         Low
      2   50      NaCl         High
      2   42      CaCl         Low
      2   48      CaCl         High
      2   27      Sand         Low
      2   31      Sand         High
      3   48      NaCl         Low
      3   52      NaCl         High
      3   47      CaCl         Low
      3   50      CaCl         High
      3   36      Sand         Low
      3   37      Sand         High
      4   44      NaCl         Low
      4   57      NaCl         High
      4   45      CaCl         Low
      4   54      CaCl         High
      4   34      Sand         Low
      4   37      Sand         High
      5   54      NaCl         Low
      5   68      NaCl         High
      5   56      CaCl         Low
      5   63      CaCl         High
      5   45      Sand         Low
      5   44      Sand         High
")

ggplot(crack.data, aes(x=interaction(Treatment,Concentration, sep=":"), 
                       y=cracks,
                       fill=interaction(Treatment,Concentration, sep=":"))) +
  geom_boxplot(show.legend = FALSE) +
  theme_minimal()

## Exercise 2

interaction.plot(x.factor=crack.data$Treatment,
                 trace.factor=crack.data$Concentration,
                 response=crack.data$cracks,
                 fun=mean,
                 xlab="Treatment", ylab="cracks",
                 trace.label = "Concentration",
                 col=c("red", "blue", "orange"), lty=1, lwd=2)

Exercise 3

Perform a factorial RCB ANOVA to determine the effect of Treatment and Concentration on the number of cracks.

library(DescTools)
Roadway <- factor( c(rep("1", 6), rep("2", 6), rep("3", 6), rep("4", 6), rep("5", 6)), levels=c("1", "2", "3", "4","5"))

Concentration <- factor(rep( c(rep("Low", 1), rep("Hi", 1)),1),
               levels=c("Low", "Hi"))

Treatment<- factor( c(rep("NaCl", 2), rep("CaCl", 2), rep("Sand", 2)), 
                    levels=c("NaCl","CaCl","Sand"))

cracks <- crack.data$cracks %>% c(1:30)

crack.data <- data.frame(Roadway=Roadway, Treatment=Treatment, Concentration=Concentration, cracks=cracks)
groadway <- ggplot(data=crack.data, aes(x=Roadway, y=cracks, fill=Roadway) ) +
  geom_boxplot(show.legend = FALSE) +
  labs(title="Cracks", subtitle="by Block (Roadway)") +
  theme_minimal()

gconcentration <- ggplot(data=crack.data, aes(x=Concentration, y=cracks, fill=Concentration) ) +
  geom_boxplot(show.legend = FALSE) +
  labs(title="Cracks", subtitle="by Concentration") +
  theme_minimal()

gtreatmeant <- ggplot(data=crack.data, aes(x=Treatment, y=cracks, fill=Treatment) ) +
  geom_boxplot(show.legend = FALSE) +
  labs(title="Cracks", subtitle="by Treatment") +
  theme_minimal()

grid.arrange(groadway, gconcentration, gtreatmeant, nrow=1, ncol=3, padding=2.0)

summary(
  RCB.model <- aov(cracks ~ Treatment*Concentration, data=crack.data)  
)
##                         Df Sum Sq Mean Sq F value Pr(>F)
## Treatment                2    452   225.9   0.706  0.498
## Concentration            1    205   205.4   0.642  0.427
## Treatment:Concentration  2     43    21.3   0.067  0.936
## Residuals               54  17278   320.0

Exercise 4

Was the blocking of roadways effective in reducing the variability in the number of cracks? Use an estimate of relative efficiency to justify your claim of effectiveness.

summary(
  RCB.model2 <- aov(cracks ~ ., data=crack.data)  
)
##               Df Sum Sq Mean Sq F value Pr(>F)  
## Roadway        4   2899   724.6   2.613 0.0458 *
## Treatment      2    452   226.0   0.815 0.4483  
## Concentration  1    205   205.3   0.740 0.3935  
## Residuals     52  14422   277.3                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Yes, it seems that blocking roadways had a significant effect on the amount of cracks.

Exercise 5

Use a Q-Q plot to determine whether the assumption of normal residuals was violated.

library("car")
## Loading required package: carData
## 
## Attaching package: 'car'
## The following object is masked from 'package:DescTools':
## 
##     Recode
## The following object is masked from 'package:dplyr':
## 
##     recode
## The following object is masked from 'package:purrr':
## 
##     some
qqPlot(crack.data$cracks)

## [1] 26 28

Exercise 6

What treatment combination results in the fewest new cracks?

PostHocTest(RCB.model, which=c("Treatment:Concentration"), method="hsd", conf.level=NA)
## 
##   Posthoc multiple comparisons of means : Tukey HSD 
## 
## $`Treatment:Concentration`
##          NaCl:Low CaCl:Low Sand:Low NaCl:Hi CaCl:Hi
## CaCl:Low 1.00     -        -        -       -      
## Sand:Low 1.00     0.98     -        -       -      
## NaCl:Hi  0.98     1.00     0.86     -       -      
## CaCl:Hi  0.98     1.00     0.88     1.00    -      
## Sand:Hi  1.00     1.00     1.00     0.94    0.95

Based on the Post Hoc Test combination, Treatment and Concentration do not seem to be signifcant in the reduction of new cracks.