Final Project

Background

Using the online Statpult and the following 5 factors with the given ranges: Fire Angle (90-140 degrees) Release Angle (Fire Angle - 180 degrees) Bungee Position (100 - 200 mm) Pin Elevation (100 - 200 mm) Cup Elevation (200 - 300 mm)

Part 1

Perform a designed experiment on the effect of Release Angle on the distance in which the ball is thrown. Specifically, we would like to study whether the settings of 175, 180, and 185 degrees significantly differ in their mean distance. Since pulling the lever back takes additional work, we would like to investigate whether this makes a significant difference on the mean distance thrown. The other factors will be set to the following Fire Angle = 90deg, Bungee Position = 200mm, Pin Elevation = 200mm, and Cup Elevation = 300mm. To test this hypothesis, we wish to use a completely randomized design with an alpha around 0.05.

Project Part 1 Set Up

library(pwr)
library(agricolae)
library(tidyr)
library(stats)

Determine how many samples should be collected to detect a mean difference with a medium effect (i.e. 50% of the standard deviation) with a probability of 75%.

Part 1 - a)

angles<-3
effect<-.5 
sig<-0.05
probability<-.75 
pwr.anova.test(k=angles, n = NULL, f = effect, sig.level = sig, power = probability)
## 
##      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 number of samples needed is 13 per group.

Propose a layout using the number of samples from part (a) with randomized run order.

Part 1 - b)

trts<-c("175", "180", "185")
rplcants<-13
numseed<-55487
design.dat = design.crd(trt = trts, r = 13, seed = numseed)
design.dat$book
##    plots  r trts
## 1    101  1  180
## 2    102  1  175
## 3    103  1  185
## 4    104  2  185
## 5    105  2  175
## 6    106  3  175
## 7    107  2  180
## 8    108  3  185
## 9    109  4  175
## 10   110  3  180
## 11   111  4  185
## 12   112  5  185
## 13   113  4  180
## 14   114  5  175
## 15   115  6  175
## 16   116  5  180
## 17   117  6  180
## 18   118  6  185
## 19   119  7  175
## 20   120  7  185
## 21   121  7  180
## 22   122  8  185
## 23   123  8  175
## 24   124  9  175
## 25   125 10  175
## 26   126 11  175
## 27   127  8  180
## 28   128  9  180
## 29   129  9  185
## 30   130 10  185
## 31   131 11  185
## 32   132 12  185
## 33   133 10  180
## 34   134 11  180
## 35   135 13  185
## 36   136 12  180
## 37   137 12  175
## 38   138 13  180
## 39   139 13  175

Collect data and record observations on layout proposed in part (b)

Part 1 - c)

Pop175 <- c(262,253,255,270,262,262,
            246,252,261,251,267,281,265)
Pop180 <- c(275,270,263,263,266,268,
            270,273,269,258,259,267,255)
Pop185 <- c(270,272,281,277,280,274,
            274,269,271,272,271,280,255)

Perform hypothesis test and check residuals. Be sure to comment and take corrective action if necessary.

\[H_0: µ_1175=µ_2180=µ_3185\] \[H_1: At\ least\ one\ of\ the\ \mu\ \neq to\ others\]

Part 1 - d)

prepop <- data.frame(Pop175,Pop180,Pop185)
Pop <- pivot_longer(prepop,c(Pop175,Pop180,Pop185))
aov(value~name, data = Pop)
## Call:
##    aov(formula = value ~ name, data = Pop)
## 
## Terms:
##                     name Residuals
## Sum of Squares   978.000  2005.231
## Deg. of Freedom        2        36
## 
## Residual standard error: 7.463301
## Estimated effects may be unbalanced
A <- aov(value~name, data = Pop)
summary(A)
##             Df Sum Sq Mean Sq F value   Pr(>F)    
## name         2    978   489.0   8.779 0.000785 ***
## Residuals   36   2005    55.7                     
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
qqnorm(A$residuals)
qqline(A$residuals)

plot(A$fitted.values,A$residuals)

boxplot(Pop$value~Pop$name)

The null hypothesis is rejected.

Based on the plots of the residuals, the anova might be invalid due to variance not being constant.

Part 1 - d1)

Since the variance is not consistent, a Kruskal-Wallace test will be performed to verify that the means are not equal.

kruskal.test(value~name, data = Pop)
## 
##  Kruskal-Wallis rank sum test
## 
## data:  value by name
## Kruskal-Wallis chi-squared = 14.355, df = 2, p-value = 0.0007637

The anova results are validated.

If the null hypothesis is rejected, investigate pairwise comparisons.

Part 1 - e)

lsdOut <- LSD.test(A,"name")
lsdValue <- lsdOut$statistics$LSD
print(lsdValue)
## [1] 5.936936
m175 <- mean(Pop175)
m180 <- mean(Pop180)
m185 <- mean(Pop185)
m175-m180
## [1] -5.307692
m175-m185
## [1] -12.23077
m180-m185
## [1] -6.923077
TukeyHSD(A)
##   Tukey multiple comparisons of means
##     95% family-wise confidence level
## 
## Fit: aov(formula = value ~ name, data = Pop)
## 
## $name
##                    diff        lwr      upr     p adj
## Pop180-Pop175  5.307692 -1.8476142 12.46300 0.1797109
## Pop185-Pop175 12.230769  5.0754627 19.38608 0.0005132
## Pop185-Pop180  6.923077 -0.2322296 14.07838 0.0596039
plot(TukeyHSD(A))

State conclusions and make recommendations.

The following pairs are significantly different: (175,185),(180,185)

The following pairs are not significantly different: (175,180)

185 degrees was significantly farther than 175 degrees.

Based on the plot provided by Tukey’s Test, 175 and 185 are significantly different

We would recommend using the 185 release angle to obtain the maximum distance.

All Code Used

Below you will find a block containing all of the code used to generate this document

library(pwr)
library(agricolae)
library(tidyr)
library(stats)

angles<-3
effect<-.5 
sig<-0.05
probability<-.75 
pwr.anova.test(k=angles, n = NULL, f = effect, sig.level = sig, power = probability)

trts<-c("175", "180", "185")
rplcants<-13
numseed<-55487
design.dat = design.crd(trt = trts, r = 13, seed = numseed)
design.dat$book

Pop175 <- c(262,253,255,270,262,262,
            246,252,261,251,267,281,265)
Pop180 <- c(275,270,263,263,266,268,
            270,273,269,258,259,267,255)
Pop185 <- c(270,272,281,277,280,274,
            274,269,271,272,271,280,255)

prepop <- data.frame(Pop175,Pop180,Pop185)
Pop <- pivot_longer(prepop,c(Pop175,Pop180,Pop185))
aov(value~name, data = Pop)
A <- aov(value~name, data = Pop)
summary(A)
qqnorm(A$residuals)
qqline(A$residuals)
plot(A$fitted.values,A$residuals)
boxplot(Pop$value~Pop$name)

kruskal.test(value~name, data = Pop)

lsdOut <- LSD.test(A,"name")
lsdValue <- lsdOut$statistics$LSD
print(lsdValue)
m175 <- mean(Pop175)
m180 <- mean(Pop180)
m185 <- mean(Pop185)
m175-m180
m175-m185
m180-m185
TukeyHSD(A)
plot(TukeyHSD(A))