1.

A chemist wishes to test the effect of four chemical agents on the strength of a particular type of cloth. Because there might be variability from one bolt to another, the chemist decides to use a randomized block design, with the bolts of cloth considered as blocks. She selects five bolts and applies all four chemicals in random order to each bolt. The resulting tensile strengths follow.

=== Bolt ===

# load data into a data frame
dat1<-read.csv("https://raw.githubusercontent.com/forestwhite/RStatistics/main/FlippedAssignment11_1.csv", header=TRUE)
names(dat1) <- sub('X', '', names(dat1))
dat1
##   Chemical  1  2  3  4  5
## 1        1 73 68 74 71 67
## 2        2 73 67 75 72 70
## 3        3 75 68 78 73 68
## 4        4 73 71 75 75 69

Analyze the data from this experiment (use α=0.15) and draw appropriate conclusions. Be sure to state the linear effects model and hypotheses being tested.

The following equation describes the components of the linear effects model:

The hypotheses to test are:

  H0: µk = µl for all k,l ∈ {1,2,3,4}
  ---OR---  τk = τl = 0 for all k,l ∈ {1,2,3,4}
  i.e. There is no significant difference in strength of the cloth based on the chemical agent.
  
  H1: µk ≠ µl for any k,l ∈ {1,2,3,4} where k ≠ l
  ---OR--- τk ≠ 0 for any k ∈ {1,2,3,4}
  i.e. There exists significant difference in the strength of the cloth based on the chemical agent.

If we assume constant variance and normality, the chemical P-value = 0.1211 < 0.15 = α, therefore we reject the null hypothesis, and at least one of the chemical agents differs from one of the others once we’ve eliminated the nuisance variability due to the bolt number.

library(GAD)
## Loading required package: matrixStats
## Loading required package: R.methodsS3
## R.methodsS3 v1.8.1 (2020-08-26 16:20:06 UTC) successfully loaded. See ?R.methodsS3 for help.
# chemical is factor (4 lvls), bolt is block (5 lvls), tensile strength is observed (n=4)#
bolt<-c(rep(1,4),rep(2,4),rep(3,4),rep(4,4),rep(5,4))
bolt
##  [1] 1 1 1 1 2 2 2 2 3 3 3 3 4 4 4 4 5 5 5 5
chemical<-c(seq(1,4),seq(1,4),seq(1,4),seq(1,4),seq(1,4))
chemical
##  [1] 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4 1 2 3 4
strength<- c(stack(dat1)[,1])[5:24]
strength
##  [1] 73 73 75 73 68 67 68 71 74 75 78 75 71 72 73 75 67 70 68 69
bolt<-as.fixed(bolt)
chemical<-as.fixed(chemical)
# x_ij=mu+t_i+beta_j+epsilon_ij
model<-lm(strength~chemical+bolt)
gad(model)
## Analysis of Variance Table
## 
## Response: strength
##          Df Sum Sq Mean Sq F value    Pr(>F)    
## chemical  3  12.95   4.317  2.3761    0.1211    
## bolt      4 157.00  39.250 21.6055 2.059e-05 ***
## Residual 12  21.80   1.817                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

2.

Assume now that she didn’t block on Bolt and rather ran the experiment at a completely randomized design on random pieces of cloth, resulting in the following data.

=== Bolt ===

# load data into a data frame
dat2<-read.csv("https://raw.githubusercontent.com/forestwhite/RStatistics/main/FlippedAssignment11-2.csv", header=TRUE)
names(dat2) <- sub('X', '', names(dat2))
dat2
##    1  2  3  4
## 1 73 73 75 73
## 2 68 67 68 71
## 3 74 75 78 75
## 4 71 72 73 75
## 5 67 70 68 69

Analyze the data from this experiment (use α=0.15) and draw appropriate conclusions. Be sure to state the linear effects model and hypotheses being tested.

The following equation describes the components of the linear effects model:

The hypotheses to test are:

  H0: µk = µl for all k,l ∈ {1,2,3,4}
  H1: µk ≠ µl for any k,l ∈ {1,2,3,4} where k ≠ l

From boxcox, our λ ≈ 1.1, and after the power transformation, the P-value = 0.764 > 0.15 = α, therefore we cannot reject the null hypothesis.

# Boxcox estimate
library(MASS)
boxcox(stack(dat2)[,1]~stack(dat2)[,2], plotit=TRUE )

# power transformation of the data using λ ≈ 1.1
dat2[,1]<-dat2[,1]^1.1
dat2[,2]<-dat2[,2]^1.1
dat2[,3]<-dat2[,3]^1.1
dat2[,4]<-dat2[,4]^1.1
dat2
##          1        2        3        4
## 1 112.1128 112.1128 115.4961 112.1128
## 2 103.6955 102.0193 103.6955 108.7387
## 3 113.8033 115.4961 120.5880 115.4961
## 4 108.7387 110.4246 112.1128 115.4961
## 5 102.0193 107.0552 103.6955 105.3741
# Verify that boxcox λ ≈ 1 after transformation = SUCCESS
boxcox(stack(dat2)[,1]~stack(dat2)[,2], plotit=TRUE )

# One-way ANOVA
aov2<-aov(values ~ ind,data=(stack(dat2)))
summary(aov2)
##             Df Sum Sq Mean Sq F value Pr(>F)
## ind          3   36.9   12.29   0.387  0.764
## Residuals   16  508.4   31.78

3.

Comment on any differences in the findings from questions 1 and 2. Do you believe that the Bolt of cloth represents a significant amount of nuisance variability?

There is evidence to suggest that the Bolt of cloth represents a significant amount of nuisance variability when under the conditions of a Randomized Complete Block Design. This is observed when the Bolt category is blocked (pβ=2.059e-5<alpha=0.15)versus when it is not. In the case when it is blocked, we can reject the null hypothesis. In the case when it is not blocked, we fail to reject the null hypothesis.

# checking significance of bolt selection variability.
gad(model)
## Analysis of Variance Table
## 
## Response: strength
##          Df Sum Sq Mean Sq F value    Pr(>F)    
## chemical  3  12.95   4.317  2.3761    0.1211    
## bolt      4 157.00  39.250 21.6055 2.059e-05 ***
## Residual 12  21.80   1.817                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Complete Code

Complete R code used in this analysis.

# load data into a data frame
dat1<-read.csv("https://raw.githubusercontent.com/forestwhite/RStatistics/main/FlippedAssignment11_1.csv", header=TRUE)
names(dat1) <- sub('X', '', names(dat1))
dat1

library(GAD)
# chemical is factor (4 lvls), bolt is block (5 lvls), tensilve strength is observed (n=4)#
bolt<-c(rep(1,4),rep(2,4),rep(3,4),rep(4,4),rep(5,4))
bolt
chemical<-c(seq(1,4),seq(1,4),seq(1,4),seq(1,4),seq(1,4))
chemical
strength<- c(stack(dat1)[,1])[5:24]
strength
bolt<-as.fixed(bolt)
chemical<-as.fixed(chemical)
# x_ij=mu+t_i+e_ij
model<-lm(strength~chemical+bolt)
gad(model)

# load data into a data frame
dat2<-read.csv("https://raw.githubusercontent.com/forestwhite/RStatistics/main/FlippedAssignment11-2.csv", header=TRUE)
names(dat2) <- sub('X', '', names(dat2))
dat2

# Boxcox estimate
library(MASS)
boxcox(stack(dat2)[,1]~stack(dat2)[,2], plotit=TRUE )

# power transformation of the data using λ ≈ 1.1
dat2[,1]<-dat2[,1]^1.1
dat2[,2]<-dat2[,2]^1.1
dat2[,3]<-dat2[,3]^1.1
dat2[,4]<-dat2[,4]^1.1
dat2

# Verify that boxcox λ ≈ 1 after transformation = SUCCESS
boxcox(stack(dat2)[,1]~stack(dat2)[,2], plotit=TRUE )

# One-way ANOVA
aov2<-aov(values ~ ind,data=(stack(dat2)))
summary(aov2)

# checking significance of bolt selection variability.
gad(model)