Answer the following question using R and RMarkdown. Use the package GAD in performing your analysis. Be sure to upload both an HTML link and pdf/doc file. Note that in Latex, you may use \(\alpha_i\) to denote the factor and \(\beta_j\) to denote the block.
library(GAD)
library(tidyr)
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. Analyze the data from this experiment (use \(\alpha = 0.15\)) and draw appropriate conclusions. Be sure to state the linear effects model and hypotheses being tested.
| Chemical | Bolt 1 | Bolt 2 | Bolt 3 | Bolt 4 | Bolt 5 |
|---|---|---|---|---|---|
| 1 | 73 | 68 | 74 | 71 | 67 |
| 2 | 73 | 67 | 75 | 72 | 70 |
| 3 | 75 | 68 | 78 | 73 | 68 |
| 4 | 73 | 71 | 75 | 75 | 69 |
\[ y_{ij}= \mu_{f} + \tau_{i} + \beta_{j} + \epsilon_{ij} ; where~i=1,2,3,4,~j=1,2,3,4,5 \]
\[ H_{0} : \mu_{1} = \mu_{2} = \mu_{3} = \mu_{4}~or~H_{0} : \tau_{i} = 0 \] \[ H_{a} : At~least~one~\mu~is~different~or~H_{a} : \tau_{i} \neq 0 \]
#create the block, completely randomized block design
# chemical is factor (4 lvls), bolt is block (5 lvls), cloth is observed (n=1)
chemical <- c(rep(1,5),rep(2,5),rep(3,5),rep(4,5))
# repeat the column row so there are 4 columns and 5 row in the data set
chemical
## [1] 1 1 1 1 1 2 2 2 2 2 3 3 3 3 3 4 4 4 4 4
#shows the vector
bolt <- c(seq(1,5),seq(1,5),seq(1,5),seq(1,5))
#bolts are in the columns and there are 4 rows in each column so repeat the sequence 4 times.
bolt
## [1] 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5 1 2 3 4 5
#shows the vector
dat <- c(73, 68, 74, 71, 67,
73, 67, 75, 72, 70,
75, 68, 78, 73, 68,
73, 71, 75, 75, 69)
dat
## [1] 73 68 74 71 67 73 67 75 72 70 75 68 78 73 68 73 71 75 75 69
#creates the observations, press enter to make it look like the table and displays it in the console
chemical <- as.fixed(chemical)
#as.fixed creates factors with fixed effects
bolt <- as.fixed(bolt)
#as.fixed creates factors with fixed effects
model_1 <- lm(dat~chemical+bolt)
# x_ij=mu+t_i+e_ij
#for the y need to add in the additive effect between chemical and bolt
gad(model_1)
## Analysis of Variance Table
##
## Response: dat
## 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
#runs the analysis of variance for model
#if p-value is very small we reject H_0, see the '*' significance codes
The Chemicals P-value = 0.1211. Both the chemical p-values is less than that of \(\alpha = 0.15\). The significance code is 0 (***), which means the bolts have more significance in the model than the chemicals. Therefore, we reject \(H_{0}\). Additionally, the Bolts P-value = 2.059e-05, but the block is not showing major significance due to the study observing the chemical effect on the tensile strength not the type of cloth.
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. Analyze the data from this experiment (use \(\alpha = 0.15\)) and draw appropriate conclusions. Be sure to state the linear effects model and hypotheses being tested.
| Chemical | Replication 1 | Replication 2 | Replication 3 | Replication 4 | Replication 5 |
|---|---|---|---|---|---|
| 1 | 73 | 68 | 74 | 71 | 67 |
| 2 | 73 | 67 | 75 | 72 | 70 |
| 3 | 75 | 68 | 78 | 73 | 68 |
| 4 | 73 | 71 | 75 | 75 | 69 |
\[ y_{ij}= \mu_{f} + \tau_{i} + \epsilon_{ij} ; where~i=1,2,3,4,~j=1,2,3,4,5 \]
\[ H_{0} : \mu_{1} = \mu_{2} = \mu_{3} = \mu_{4}~or~H_{0} : \tau_{i} = 0 \] \[ H_{a} : At~least~one~\mu~is~different~or~H_{a} : τ~i~ \neq 0 \]
model_2 <- lm(dat~chemical)
# x_ij=mu+t_i+e_ij
#for the y we only include checmical since there is no blocking
gad(model_2)
## Analysis of Variance Table
##
## Response: dat
## Df Sum Sq Mean Sq F value Pr(>F)
## chemical 3 12.95 4.3167 0.3863 0.7644
## Residual 16 178.80 11.1750
#runs the analysis of variance for model
#if p-value is very small we reject H_0, see the '*' significance codes
The Chemicals P-value = 0.7644, which is greater than \(\alpha = 0.15\). Therefore, we fail to reject \(H_{0}\). No significance code is noted. Due to the study observing the chemical effect on the tensile strength not the type of cloth (using random bolts of cloth), we do not need to analyze the bolts of cloth in the model.
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?
Since the F-value (2.3761) is a ratio of MST over MSE we can assume that the larger the ratio, the larger the effect of the blocks. The Bolts F value is much larger than the Chemical F value in model 1; therefore, the Bolts of cloth do represent a significant amount of nuisance variability in the data set 1. In data set 2, the bolts of cloth were randomized, so the F value is only calculated for the chemical. The F-value (0.3863) for the model 2 is much smaller when using random bolts of cloth, so it is cannot be determined which bolt of cloth has significance. In comparison, the type of bolt cloth does have an response to the type of chemical. Therefore, the Bolts of cloth significant amount of nuisance variability cannot be determined in the data set 2. Overall, the the Bolts of cloth do represent a significant amount of nuisance variability.
library(GAD)
library(tidyr)
## QUESTION 1 ##
#create the block, completely randomized block design
# chemical is factor (4 lvls), bolt is block (5 lvls), cloth is observed (n=5)
chemical <- c(rep(1,5),rep(2,5),rep(3,5),rep(4,5))
# repeat the column row so there are 4 columns and 5 row in the data set
chemical
#shows the vector
bolt <- c(seq(1,5),seq(1,5),seq(1,5),seq(1,5))
#bolts are in the columns and there are 4 rows in each column so repeat the sequence 4 times.
bolt
#shows the vector
dat <- c(73, 68, 74, 71, 67,
73, 67, 75, 72, 70,
75, 68, 78, 73, 68,
73, 71, 75, 75, 69)
dat
#creates the observations, press enter to make it look like the table and displays it in the console
chemical <- as.fixed(chemical)
#as.fixed creates factors with fixed effects
bolt <- as.fixed(bolt)
#as.fixed creates factors with fixed effects
model_1 <- lm(dat~chemical+bolt)
# x_ij=mu+t_i+e_ij
#for the y need to add in the additive effect between chemical and bolt
gad(model_1)
#runs the analysis of variance for model
#if p-value is very small we reject H_0, see the '*' significance codes
## QUESTION 2 ##
model_2 <- lm(dat~chemical)
# x_ij=mu+t_i+e_ij
#for the y we only include checmical since there is no blocking
gad(model_2)
#runs the analysis of variance for model
#if p-value is very small we reject H_0, see the '*' significance codes