PART A:
Reading the Data:
Obs <- c(12,18,13,20,17,25,15,25,10,24,13,24,19,21,17,23)
a <- c(-1,1)
b <- c(-1,-1,1,1)
c <- c(-1,-1,-1,-1,1,1,1,1)
d <- c(-1,-1,-1,-1,-1,-1,-1,-1,1,1,1,1,1,1,1,1)
A <- c(rep(a,8))
B <- c(rep(b,4))
C <- c(rep(c,2))
D <- c(rep(d,1))
Data <- data.frame(A,B,C,D,Obs)
Data
## A B C D Obs
## 1 -1 -1 -1 -1 12
## 2 1 -1 -1 -1 18
## 3 -1 1 -1 -1 13
## 4 1 1 -1 -1 20
## 5 -1 -1 1 -1 17
## 6 1 -1 1 -1 25
## 7 -1 1 1 -1 15
## 8 1 1 1 -1 25
## 9 -1 -1 -1 1 10
## 10 1 -1 -1 1 24
## 11 -1 1 -1 1 13
## 12 1 1 -1 1 24
## 13 -1 -1 1 1 19
## 14 1 -1 1 1 21
## 15 -1 1 1 1 17
## 16 1 1 1 1 23
Running the Model:
Model <- lm(Obs~A*B*C*D,data = Data)
coef(Model)
## (Intercept) A B C D A:B
## 18.500 4.000 0.250 1.750 0.375 0.250
## A:C B:C A:D B:D C:D A:B:C
## -0.750 -0.500 0.125 0.125 -0.625 0.500
## A:B:D A:C:D B:C:D A:B:C:D
## -0.125 -1.375 0.125 0.375
Plotting Half Normal Plot:
library(DoE.base)
halfnormal(Model)
Comment:
--> We can see from above that significant factors in model are A,D,AD and AC .As these are fall far away from the normal line.PART B:
Writing the Hypothesis for two interaction and 3 main effects:
Null: \(H_o\)\[ (\alpha\gamma)_{i,k}=0 \]
\[ (\alpha\lambda)_{i,l}=0 \]
\[ \alpha_{i}=0 \]
\[ \gamma_{k}=0 \]
\[ \lambda_{l}=0 \]
Alternate: \(H_a\)
\[ (\alpha\gamma)_{i,k}\neq0 \]
\[ (\alpha\lambda)_{i,l}\neq0\]
\[ \alpha_{i}\neq0 \]
\[ \gamma_{k}\neq0 \]
\[ \lambda_{l}\neq0 \]
As AD and AC are also significant hence following are factors that we will have to consider A, C , D, AC , AD
Model1 <- aov(Obs~A+C+D+A*C+A*D,data = Data)
summary(Model1)
## Df Sum Sq Mean Sq F value Pr(>F)
## A 1 256.00 256.00 51.717 2.96e-05 ***
## C 1 49.00 49.00 9.899 0.0104 *
## D 1 2.25 2.25 0.455 0.5155
## A:C 1 9.00 9.00 1.818 0.2073
## A:D 1 0.25 0.25 0.051 0.8267
## Residuals 10 49.50 4.95
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
library(ggfortify)
library(ggplot2)
autoplot(Model1)
Analysis of the residuals indicates that the model is viable (constant variance, normality).
Conclusion:
--> All the tested main effects (A,C,D) appears to be significant at alpha =0.05. Also the interaction term (AC & AD) appears to be significant at alpha = 0.05P-Value for A = 3.45 e^-5
P-Value for C = 0.01054
P-Value for D = 0.0004647
P-Value for AC = 5.83 e^-5
P-Value for AD = 9.19 e^-5
Plotting Interaction Graphically for Analysis:
Interaction Plots:
interaction.plot(A,D,Obs)
interaction.plot(A,C,Obs)