Project Part 2

Model Equation for two factor interaction:

\(Y_{ijk} = \mu_i + \alpha_i + \beta_j + \alpha\beta_{ij} + \epsilon_{ijk}\)

Where

\(\alpha_i\) is Main Effects of Factor A (pin elevation)

\(\beta_j\) is Main Effects of Factor B (Release Angle)

\(\alpha\beta_{ij}\) is Interaction effects of Factors A and Factors B

Hypothesis to be tested

Null Hypothesis(Ho): \(\alpha_i=0\) For all i

Alternative Hypothesis(Ha): \(\alpha_i\neq0\) For some i

Null Hypothesis(Ho): \(\sigma^2\beta =0\)

Alternative Hypothesis(Ha): \(\sigma^2\beta\neq0\)

Null Hypothesis(Ho): \(\sigma^2\alpha\beta=0\)

Alternative Hypothesis(Ha):\(\alpha\beta_{ij}\neq0\)

we will test first highest order interaction effects hypothesis

Null Hypothesis(Ho): \(\sigma^2\alpha\beta=0\)

Alternative Hypothesis(Ha):\(\alpha\beta_{ij}\neq0\)

Here we know, I=2, J=3 and k=3

Level of significance at which we are testing the hypothesis is 0.05

Notations

Factor A (pin elevation)

Pin position 1(bottom) is denoted by “1”

Pin position 3(top) is denoted by “2”

Also, for Factor B (Release Angle)

Release angle of 110 degree is denoted by “1”

Release angle of 140 degree is denoted by “2”

Release angle of 170 degree is denoted by “3”

Now, we need to generate Completely Randomized Design with equal or different repetition to perform a designed experiment to determine the effect of the release angle and pin position on the experiment.

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.
library(agricolae)
treat<-c(2,3)
d<-design.ab(treat,3,design = "crd",seed= 1111644)
design<-d$book
design
##    plots r A B
## 1    101 1 1 2
## 2    102 1 1 3
## 3    103 2 1 3
## 4    104 2 1 2
## 5    105 1 2 2
## 6    106 3 1 3
## 7    107 1 2 1
## 8    108 2 2 2
## 9    109 1 2 3
## 10   110 1 1 1
## 11   111 3 2 2
## 12   112 2 2 1
## 13   113 2 2 3
## 14   114 2 1 1
## 15   115 3 1 1
## 16   116 3 2 3
## 17   117 3 2 1
## 18   118 3 1 2

Collecting the data according to the randomized generated design

factorA <-c("1","1","1","1","2","1","2","2","2","1","2","2","2","1","1","2","2","1")
factorB <-c("2","3","3","2","2","3","1","2","3","1","2","1","3","1","1","3","1","2")
observations <- c(37,54,60,45,49,49,30,53,67,30,49,33,63,33,29,72,35,51)
df<- data.frame(factorA,factorB,observations)

According to the problem statement we have been told to investigate the settings “1” and “3” of Pin Elevation as the fixed effects and settings of the Release Angle corresponding to “110”, “140”, and “170” degrees as a random effects

df$factorA <- as.fixed(df$factorA)
df$factorB <- as.random(df$factorB)
df
##    factorA factorB observations
## 1        1       2           37
## 2        1       3           54
## 3        1       3           60
## 4        1       2           45
## 5        2       2           49
## 6        1       3           49
## 7        2       1           30
## 8        2       2           53
## 9        2       3           67
## 10       1       1           30
## 11       2       2           49
## 12       2       1           33
## 13       2       3           63
## 14       1       1           33
## 15       1       1           29
## 16       2       3           72
## 17       2       1           35
## 18       1       2           51

Now to test the hypothesis we will perform the ANOVA test and gad(model)

model<- aov(observations~factorA+factorB+factorA*factorB,data = df)
GAD::gad(model)
## Analysis of Variance Table
## 
## Response: observations
##                 Df Sum Sq Mean Sq F value    Pr(>F)    
## factorA          1  220.5  220.50  4.7419    0.1613    
## factorB          2 2556.8 1278.39 66.1236 3.315e-07 ***
## factorA:factorB  2   93.0   46.50  2.4052    0.1323    
## Residual        12  232.0   19.33                      
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

From the results of the ANOVA and gad model test, the p-value of interaction of factorA and FactorB is 0.1323. As p-value is greater than the alpha 0.05, we conclude that we failed to reject the null hypothesis.Hence we conclude that interaction is not significant

p-value of Factor A is 0.1613

p-value of Factor B is 3.315e-07

To get better idea about the interaction effects of FactorA and FactorB we will plot interaction plots

interaction.plot(factorA, factorB,observations, type = "l", ylab = "obs", xlab = "FactorA", main = "Interaction Plot", col = c("darkred", "black"))

From interaction plots we can see that the interaction is not significant

Now we will perform the ANOVA Test and gad model without considering the interaction

model1 <- aov(observations~factorA+factorB,data = df)
GAD::gad(model1)
## Analysis of Variance Table
## 
## Response: observations
##          Df Sum Sq Mean Sq F value   Pr(>F)    
## factorA   1  220.5  220.50  9.4985 0.008118 ** 
## factorB   2 2556.8 1278.39 55.0691 2.32e-07 ***
## Residual 14  325.0   23.21                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

From the results of the ANOVA and gad model test, the p-value of factorA and factorB is 0.008118 and 2.32e-07 respectively. As p-value is lower than the alpha 0.05, we conclude that we reject the null hypothesis and main effects are significant.

plot(model,col="darkred")

From the residual plot we can conclude that the our data is normally distributed except few out liners

From residuals vs fitted plots we can see that variances are widely spread, hence we conclude that variances are not constant

library(GAD)
library(agricolae)
treat<-c(2,3)
d<-design.ab(treat,3,design = "crd",seed= 1111644)
design<-d$book
design
factorA <-c("1","1","1","1","2","1","2","2","2","1","2","2","2","1","1","2","2","1")
factorB <-c("2","3","3","2","2","3","1","2","3","1","2","1","3","1","1","3","1","2")
observations <- c(37,54,60,45,49,49,30,53,67,30,49,33,63,33,29,72,35,51)
df<- data.frame(factorA,factorB,observations)
df$factorA <- as.fixed(df$factorA)
df$factorB <- as.random(df$factorB)
df
model <- aov(observations~factorA+factorB+factorA*factorB,data = df)
GAD::gad(model)
interaction.plot(factorA, factorB,observations, type = "l", ylab = "obs", xlab = "FactorA", main = "Interaction Plot", col = c("darkred", "black"))
model1 <- aov(observations~factorA+factorB,data = df)
GAD::gad(model1)
plot(model,col="darkred")