Project Part 2
A) State model equation with the null and alternative hypotheses to be tested. In addition. state the level of significance that will be used in your analysis.
Model equation:
\(Y_{ijk}=\mu+\alpha_{i}+\beta_{j}+\alpha\beta_{ij}+e_{ijk}\)
The level of significance for this analysis is \(\alpha=0,05\)
B) Propose a layout with a randomized run order.
library(agricolae)
trts<-c(2,3)
design.ab(trt=trts, r=3, design="crd", randomization=TRUE, seed=156812)
## $parameters
## $parameters$design
## [1] "factorial"
##
## $parameters$trt
## [1] "1 1" "1 2" "1 3" "2 1" "2 2" "2 3"
##
## $parameters$r
## [1] 3 3 3 3 3 3
##
## $parameters$serie
## [1] 2
##
## $parameters$seed
## [1] 156812
##
## $parameters$kinds
## [1] "Super-Duper"
##
## $parameters[[7]]
## [1] TRUE
##
## $parameters$applied
## [1] "crd"
##
##
## $book
## plots r A B
## 1 101 1 2 3
## 2 102 1 1 3
## 3 103 1 2 2
## 4 104 1 2 1
## 5 105 2 2 3
## 6 106 1 1 2
## 7 107 2 1 3
## 8 108 2 1 2
## 9 109 1 1 1
## 10 110 2 1 1
## 11 111 2 2 2
## 12 112 2 2 1
## 13 113 3 1 1
## 14 114 3 2 2
## 15 115 3 2 3
## 16 116 3 1 3
## 17 117 3 2 1
## 18 118 3 1 2
The layout for the design proposed is showed above.
C) Collect data and record observations on the layout proposed in part (A)
Data was collected during the class and the data are showed below:
Angle<-rep(seq(1,3), 3)
Pin<-c(rep(1,9), rep(2,9))
Dist<-c(27,42,49,
27,38,51,
26,40,50,
33,49,79,
29,46,63,
29,43,67)
Dat<-data.frame(Pin,Angle,Dist)
D) Test the hypotheses and state conclusions, determining those effects that are significant. Show any plots that might be useful/necessary to show your findings. You may also show residual plots and make appropriate comments, but do not transform the data (i.e. use the raw data regardless of normality and variance constancy).
Answers
Hypothesis for Mixed effects.
Interaction Pin (Fixxed) and Angle (Random)
Null hypothesis: \(H_0: \sigma^2_{\alpha\beta}=0\)
Alternative hypothesis: \(H_1: \sigma^2_{\alpha\beta}!0\)
Factor Pin (Fixxed)
Null hypothesis: \(H_0: \alpha_{i}=0\)
Alternative hypothesis: \(H_1: \alpha_{i}!0\)
Factor Angle (Random)
Null hypothesis: \(H_0: \sigma^2_{\beta}=0\)
Alternative hypothesis: \(H_1: \sigma^2_{\beta}!0\)
Testing the hypothesis
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.
Dat$Pin<-as.fixed(Dat$Pin)
Dat$Angle<-as.random(Dat$Angle)
Model<-aov(Dist~Angle+Pin+Angle*Pin, data = Dat)
GAD::gad(Model)
## Analysis of Variance Table
##
## Response: Dist
## Df Sum Sq Mean Sq F value Pr(>F)
## Angle 2 2950.78 1475.39 99.4644 3.391e-08 ***
## Pin 1 430.22 430.22 3.8394 0.189138
## Angle:Pin 2 224.11 112.06 7.5543 0.007524 **
## Residual 12 178.00 14.83
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
Analysis
With the p-value=0.007524 < than \(\alpha=0,05\), we reject the Null hypothesis (\(H_0: \sigma^2_{\alpha\beta}=0\)) and conclude the interaction between the factors Pin and Angle are significant and affect the distance in which a red ball is thrown.
With the p-value=0.189138 greater than \(\alpha=0,05\),we fail to reject the null hypothesis (\(H_0: \alpha_{i}=0\)) and conclude the factor Pin by himself has not a significant effect in the distance in which a red ball is thrown.
With the p-value=3.391e-08 very less than \(\alpha=0,05\), we reject the Null Hypothesis (\(H_0: \sigma^2_{\beta}=0\)) and conclude the Factor Angle has a significant effect in the distance in which a red ball is thrown.
Graph Analysis
From the Residual vs fitted plot, we can se a outward-opening funnel shape, which indicates the variance of the observations is not constant. From the Normal Q-Q plot, we can say that all the points approximately lies in the straight line, so the data is normally distributed.
In the all plots we also can see the presence of outliers. These outliers may represent the variabilities in the experiment, for example, the operator. In this experiment the operator needed to sit on the floor in an uncomfortable position to perform the experiment. Another possible variability might be the time, since there were many groups to collect data during the class period, so, we had a concern about collecting the data fast.
Interaction Plot
Dat1<-data.frame(Pin,Angle,Dist)
Dat1$Pin<-as.factor(Dat1$Pin)
Dat1$Angle<-as.factor(Dat1$Angle)
interaction.plot(x.factor = Dat1$Angle,
trace.factor = Dat1$Pin,
response = Dat1$Dist,
fun = mean,
type="b",
col=c("black","red","green"),
pch=c(19, 17, 15),
fixed=TRUE,
leg.bty = "o")

Graph Analysis
However in this plot we cannot vizualize the crossing of lines, In this interaction plot, we can se the lines are not parallel, indicating the interaction between factors. Furthermore,this interaction effect indicates that the relationship between pin position and distance depends on the value of the angle.
This graph agreed with the results of the analysis of variance indicate that the interaction between Pin and Angle is significant.
All Code
library(agricolae)
trts<-c(2,3)
design.ab(trt=trts, r=3, design="crd", randomization=TRUE, seed=156812)
Angle<-rep(seq(1,3), 3)
Pin<-c(rep(1,9), rep(2,9))
Dist<-c(27,42,49,
27,38,51,
26,40,50,
33,49,79,
29,46,63,
29,43,67)
Dat<-data.frame(Pin,Angle,Dist)
library(GAD)
Dat$Pin<-as.fixed(Dat$Pin)
Dat$Angle<-as.random(Dat$Angle)
Model<-aov(Dist~Angle+Pin+Angle*Pin, data = Dat)
GAD::gad(Model)
plot(Model)
Dat1<-data.frame(Pin,Angle,Dist)
Dat1$Pin<-as.factor(Dat1$Pin)
Dat1$Angle<-as.factor(Dat1$Angle)
interaction.plot(x.factor = Dat1$Angle,
trace.factor = Dat1$Pin,
response = Dat1$Dist,
fun = mean,
type="b",
col=c("black","red","green"),
pch=c(19, 17, 15),
fixed=TRUE,
leg.bty = "o")