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
dat43<-read.csv("https://raw.githubusercontent.com/forestwhite/RStatistics/main/43Table.csv", header=TRUE)
names(dat43) <- sub('X', '', names(dat43))
dat43
## 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.05) and draw appropriate conclusions.
If we assume constant variance and normality, the chemical P-value = 0.1211 > 0.05 = α, therefore we cannot reject the null hypothesis, and we cannot assume any of the means differ significantly from one another after eliminating 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(dat43)[,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)
model43<-lm(strength~chemical+bolt)
gad(model43)
## 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
Assuming that chemical types and bolts are fixed, estimate the model parameters τi and βj in Problem 4.3.
Because we could not reject the null hypothesis, the alternate hypothesis H1: τk ≠ 0 for any k ∈ {1,2,3,4} is true for some or all of the treatments.
We approximate τi and βj using the following equations:
τ1 ≈ 70.6 - 71.75 = -1.15 τ2 ≈ 71.4 - 71.75 = -0.35 τ3 ≈ 72.4 - 71.75 = 0.65 τ4 ≈ 72.6 - 71.75 = 0.85 β1 ≈ 73.5 - 71.75 = 1.75 β2 ≈ 68.5 - 71.75 = -3.25 β3 ≈ 75.5 - 71.75 = 3.75 β4 ≈ 72.75 - 71.75 = 1 β5 ≈ 68.5 - 71.75 = -3.25
The effect of five different ingredients (A, B, C, D, E) on the reaction time of a chemical process is being studied. Each batch of new material is only large enough to permit five runs to be made. Furthermore, each run requires approximately 1 1/2 hours, so only five runs can be made in one day. The experimenter decides to run the experiment as a Latin square so that day and batch effects may be systematically controlled. She obtains the data that follow.
# load data into a data frame
dat422<-read.csv("https://raw.githubusercontent.com/forestwhite/RStatistics/main/422Table.csv", header=TRUE)
names(dat422) <- sub('X', '', names(dat422))
dat422
## Batch Day Ingredient Reaction_Time
## 1 1 1 A 8
## 2 1 2 B 7
## 3 1 3 D 1
## 4 1 4 C 7
## 5 1 5 E 3
## 6 2 1 C 11
## 7 2 2 E 2
## 8 2 3 A 7
## 9 2 4 D 3
## 10 2 5 B 8
## 11 3 1 B 4
## 12 3 2 A 9
## 13 3 3 C 10
## 14 3 4 E 1
## 15 3 5 D 5
## 16 4 1 D 6
## 17 4 2 C 8
## 18 4 3 E 6
## 19 4 4 B 6
## 20 4 5 A 10
## 21 5 1 E 4
## 22 5 2 D 2
## 23 5 3 B 3
## 24 5 4 A 8
## 25 5 5 C 8
Analyze the data from this experiment (use α = 0.05) and draw conclusions.
pIngredient = 0.0004877 < 0.05 = α, so we can reject the null hypothesis and the choice of ingredient is significant after removing nuisance factors by using a block design. The nuisance variables both have P-values > 0.05, so we try analysis without the blocks and pIngredient non-blocking = 7.672e-05 < 0.05 = α, so we can reject the null hypothesis and the choice of ingredient is significant even without blocking.
# change block variables into factors
dat422$Batch <- as.factor(dat422$Batch)
dat422$Day <- as.factor(dat422$Day)
dat422$Ingredient <- as.factor(dat422$Ingredient)
str(dat422)
## 'data.frame': 25 obs. of 4 variables:
## $ Batch : Factor w/ 5 levels "1","2","3","4",..: 1 1 1 1 1 2 2 2 2 2 ...
## $ Day : Factor w/ 5 levels "1","2","3","4",..: 1 2 3 4 5 1 2 3 4 5 ...
## $ Ingredient : Factor w/ 5 levels "A","B","C","D",..: 1 2 4 3 5 3 5 1 4 2 ...
## $ Reaction_Time: int 8 7 1 7 3 11 2 7 3 8 ...
# Apply analysis of variance model
model422 <- lm(Reaction_Time ~ Batch+Day+Ingredient, dat422)
anova(model422)
## Analysis of Variance Table
##
## Response: Reaction_Time
## Df Sum Sq Mean Sq F value Pr(>F)
## Batch 4 15.44 3.860 1.2345 0.3476182
## Day 4 12.24 3.060 0.9787 0.4550143
## Ingredient 4 141.44 35.360 11.3092 0.0004877 ***
## Residuals 12 37.52 3.127
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#Apply analysis of variance without blocking
model422_nb <- lm(Reaction_Time ~ Ingredient, dat422)
anova(model422_nb)
## Analysis of Variance Table
##
## Response: Reaction_Time
## Df Sum Sq Mean Sq F value Pr(>F)
## Ingredient 4 141.44 35.36 10.847 7.672e-05 ***
## Residuals 20 65.20 3.26
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Here we display the complete R code used in this analysis.
# load data into a data frame
dat43<-read.csv("https://raw.githubusercontent.com/forestwhite/RStatistics/main/43Table.csv", header=TRUE)
names(dat43) <- sub('X', '', names(dat43))
dat43
library(GAD)
# 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
chemical<-c(seq(1,4),seq(1,4),seq(1,4),seq(1,4),seq(1,4))
chemical
strength<- c(stack(dat43)[,1])[5:24]
strength
bolt<-as.fixed(bolt)
chemical<-as.fixed(chemical)
model43<-lm(strength~chemical+bolt)
gad(model43)
# load data into a data frame
dat422<-read.csv("https://raw.githubusercontent.com/forestwhite/RStatistics/main/422Table.csv", header=TRUE)
names(dat422) <- sub('X', '', names(dat422))
dat422
# change block variables into factors
dat422$Batch <- as.factor(dat422$Batch)
dat422$Day <- as.factor(dat422$Day)
dat422$Ingredient <- as.factor(dat422$Ingredient)
str(dat422)
# Apply analysis of variance model
model422 <- lm(Reaction_Time ~ Batch+Day+Ingredient, dat422)
anova(model422)
#Apply analysis of variance without blocking
model422_nb <- lm(Reaction_Time ~ Ingredient, dat422)
anova(model422_nb)