Our goal here is to compare the distance 3 different types of balls will go when thrown from a contraption known as a statapult. An example of the 3 different kinds of balls is shown below, with (from left to right) Foam, Tennis, and an unknown Rubber Composite.
Ball Types
A statapult is essentially a small catapult, with a measurement system available to show the angle of tension in the rubber band that provides the throwing force. For this experiment, we pulled the catapult all the way over to an angle of 90 degrees (parallel with the floor) for each throw.
library(pwr)
pwr.anova.test(k=3,n=NULL,f=.5,sig.level=.05,power=.75)
##
## Balanced one-way analysis of variance power calculation
##
## k = 3
## n = 12.50714
## f = 0.5
## sig.level = 0.05
## power = 0.75
##
## NOTE: n is number in each group
The result of this tells us we needed to have 13 samples of each type of ball in order to meet our given design criteria. Our significance level was .05, meaning our probability of correctly identifying a difference in means is 95%. Our power level is chosen to be 75%, and the effect size .5.
In order to remove any bias from our experiment, we performed a completely randomized design test, generated by R. Shown below is the order that our balls were thrown in, with each ball having a total of 13 throws (for a grand total of 39 entries). The distance was recorded in inches by a member of the team, who measured for where the ball first landed when thrown, regardless of any further bounce or roll.
types <- c('Foam','Tennis','Rubber')
library(agricolae)
design <- design.crd(trt=types,r=13,seed=8238350)
design$book
## plots r types
## 1 101 1 Rubber
## 2 102 2 Rubber
## 3 103 1 Foam
## 4 104 1 Tennis
## 5 105 2 Tennis
## 6 106 2 Foam
## 7 107 3 Tennis
## 8 108 3 Foam
## 9 109 3 Rubber
## 10 110 4 Rubber
## 11 111 5 Rubber
## 12 112 4 Tennis
## 13 113 6 Rubber
## 14 114 7 Rubber
## 15 115 8 Rubber
## 16 116 5 Tennis
## 17 117 4 Foam
## 18 118 9 Rubber
## 19 119 5 Foam
## 20 120 6 Foam
## 21 121 10 Rubber
## 22 122 6 Tennis
## 23 123 7 Tennis
## 24 124 7 Foam
## 25 125 11 Rubber
## 26 126 8 Tennis
## 27 127 9 Tennis
## 28 128 10 Tennis
## 29 129 8 Foam
## 30 130 9 Foam
## 31 131 10 Foam
## 32 132 11 Foam
## 33 133 12 Foam
## 34 134 13 Foam
## 35 135 12 Rubber
## 36 136 13 Rubber
## 37 137 11 Tennis
## 38 138 12 Tennis
## 39 139 13 Tennis
An example of our experiment data is shown below. The full file of data can be seen at https://raw.githubusercontent.com/1212raegan/IE-5342-Assignments/main/Project%20P1%20(1).csv
## Distance Type
## 1 60 Foam
## 2 63 Foam
## 3 58 Foam
## 4 61 Foam
## 5 60 Foam
## 6 57 Foam
We then performed an ANOVA test to see if our data showed a significant difference between ball type. Here, our Null hypothesis is that the means of these 3 samples are statistically equal, and the alternative hypothesis is that they are not.
Ho: \(\mu1=\mu2=\mu3\)
Ha: \(\mu1\neq\mu2\neq\mu3\)
anovatest <- aov(Distance~Type,data=dat)
summary(anovatest)
## Df Sum Sq Mean Sq F value Pr(>F)
## Type 2 216.7 108.3 10.51 0.000253 ***
## Residuals 36 370.9 10.3
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
We can see here that our P value is .000253(well below our alpha of .05), meaning our data does show a significant difference in mean distance given ball type, and we reject the null hypothesis.
Given that ANOVA result, we then checked to see if the model was adequate by looking at our variances and residuals for any patterns or indications of assumption violations.
We can see from our plots of residuals that our variance does seem to be roughly equal between ball types, and our data is normally distributed based on the Q-Q plot.
Our data also passes the ‘fat pencil test’ where it says that of all the data points in the normal probability plot are covered by a hypothetical fat pencil then it is normally distributed.
We perform the Tukey’s test to find which types in particular showed a significant difference in means. Here, our null hypothesis is that each separate pairs of ball type means are not different from one another.
Ho: \(\mu1-\mu2=0\)
Ha: \(\mu1-\mu2\neq0\)
(run for every combination of the 3 types)
TukeyHSD(anovatest)
## Tukey multiple comparisons of means
## 95% family-wise confidence level
##
## Fit: aov(formula = Distance ~ Type, data = dat)
##
## $Type
## diff lwr upr p adj
## Rubber-Foam -2.692308 -5.769736 0.3851209438 0.0962519
## Tennis-Foam -5.769231 -8.846659 -2.6918021331 0.0001550
## Tennis-Rubber -3.076923 -6.154352 0.0005055592 0.0500450
plot(TukeyHSD(anovatest))
According to Tukey’s test, a difference in means was spotted between the Tennis ball and the Foam ball. This can be seen in the graph above, showing that Tennis vs Foam is the only one of the pairs to not cross 0.
We can see this difference between the means in a more intuitive sense by plotting the distances for each type:
library(ggplot2)
ggplot(dat,aes(Distance,Type,color=Type))+geom_point(size=3)
As we can see, it’s clear that Foam and Tennis seem to be sortof centered around two different areas (51 and 58, respectively), while Rubber varies greatly. This corroborates with what we saw in the residual graphs as well, with one sample showing a wider spread then the other two.
library(pwr)
pwr.anova.test(k=3,n=NULL,f=.5,sig.level=.05,power=.75)
types <- c('Foam','Tennis','Rubber')
library(agricolae)
design <- design.crd(trt=types,r=13,seed=8238350)
design$book
library(readxl)
dat=read.csv('https://raw.githubusercontent.com/1212raegan/IE-5342-Assignments/main/Project%20P1%20(1).csv')
colnames(dat) <- c('Distance','Type')
dat$Type <- factor(dat$Type)
head(dat)
anovatest <- aov(Distance~Type,data=dat)
summary(anovatest)
par(mfcol=c(1,2))
resonfit <- plot(anovatest,which=1)
stdresonfit <- plot(anovatest,which=3)
qq <- plot(anovatest,which=2)
stdresonfacotr <- plot(anovatest,which=5)
TukeyHSD(anovatest)
plot(TukeyHSD(anovatest))
library(ggplot2)
ggplot(dat,aes(Distance,Type,color=Type))+geom_point(size=3)