library(mosaic)library(DT)library(pander)library(car)library(tidyverse)library(lattice)library(dplyr)library(ggplot2)library(knitr)library(swirl)# Record your data from your own mini experiment in Excel.# Save the data as a .csv file in the Data folder of the Statistics-Notebook.mm <-read_csv("../../data/MarshmallowSplitPlot.csv")mm$angle <-as.factor(mm$angle)mm$person <-as.factor(mm$person)mm$marshmallow <-as.factor(mm$marshmallow)
We randomized our data via the excel and r. We labeled 10 different marshmallows (our blocking factor) and randomized each one to one of our between factor and each marshmallow received our within factor. Our between blocks factor is Cali vs Stephanie shooting the marshmallows off of a spoon and our within blocks if if they shot the mashmallows sitting or standing. We taped a target to the floor and measured how close the marshmallow landed to the center of the target (measured in centimeters).
We randomized the order of which marshmallow would be shot off first either sitting and standing, ensuring that each marshmallow was shot off both sitting and standing angles.
marshmallow is nested within person.
Show the code
library(dplyr)mm <- mm %>%select(person, marshmallow, angle, cm, order)
\alpha = 0.1
(Alpha is set to 0.1 because the data was weird and I expect a lot of variation). ————————————————————————
Show the code
mm.aov <-aov(cm ~ person +Error(marshmallow) + angle + person:angle, data = mm)summary(mm.aov) %>%pander()
Df
Sum Sq
Mean Sq
F value
Pr(>F)
person
1
484.1
484.1
0.4888
0.5043
Residuals
8
7924
990.5
NA
NA
angle
1
2473
2473
3.781
0.08775
person:angle
1
250.6
250.6
0.3831
0.5531
Residuals
8
5233
654.2
NA
NA
We are seeing that only the angle is significant with a 0.1 alpha 0.09 < \alpha. Let’s take a closer look with graphs and numeric summaries.
Person Graph
Show the code
## lets go a ggplot that's real sexy likelibrary(ggplot2)library(dplyr)ggplot(mm, aes(x=person, y=cm)) +geom_boxplot(aes(fill = person)) +theme_bw() +scale_fill_manual(values =c("cadetblue1", "seagreen", "gray")) +labs(title ="Distance to Target Achieved by Stephanie and Cali",fill ="Person",x ="Person",y ="Distance from Center of Target (cm)")
The averages are very close as depicted in this graph and there are is not too much variation either.
Person Numerical Summary
Show the code
mm %>%group_by(person) %>%summarise(Average =mean(cm, na.rm =TRUE),Min =min(cm, na.rm =TRUE), Med =median(cm, na.rm =TRUE), Max =max(cm, na.rm =TRUE),StDev =sd(cm, na.rm =TRUE), SampleSize =n() ) %>%pander()
person
Average
Min
Med
Max
StDev
SampleSize
Cali
61.38
12.2
68.25
107.8
29.73
10
Stephanie
71.22
15.3
73.2
107.6
29.67
10
Not significant.
Angle Graph
Show the code
## lets go a ggplot that's real sexy likelibrary(ggplot2)library(dplyr)ggplot(mm, aes(x=angle, y=cm)) +geom_boxplot(aes(fill = angle)) +theme_bw() +scale_fill_manual(values =c("firebrick", "goldenrod")) +labs(title ="Angle Affecting Distance to Target",fill ="Angle",x ="Angle",y ="Distance from Center (cm)")
Stand has so much variance, the marshmallow shot off while standing had so much variance from the target whereas sitting led to closer standard deviation as depicted in the numerical summary below.
Angle Numerical Summary
Show the code
mm %>%group_by(angle) %>%summarise(Average =mean(cm, na.rm =TRUE),Min =min(cm, na.rm =TRUE), Med =median(cm, na.rm =TRUE), Max =max(cm, na.rm =TRUE),StDev =sd(cm, na.rm =TRUE), SampleSize =n() ) %>%pander()
angle
Average
Min
Med
Max
StDev
SampleSize
sit
77.42
46.8
78.1
107.8
19.09
10
stand
55.18
12.2
65.45
107.6
34.34
10
These averages look very different, and from the anova test we see that it is significant.
Interaction Graph
Show the code
xyplot(cm ~ angle, data = mm, groups=person, type=c("p","a"), auto.key=TRUE, main="How Angle by Person Affects Accuracy to Target", ylab="Distance from Center (cm)", xlab="Angle")
Stand has the closest to the target over sit with Cali having the marshmallow that got the closest to the target.
Interaction Numerical Summary
Show the code
mm %>%group_by(person, angle) %>%summarise(Average =mean(cm, na.rm =TRUE),Min =min(cm, na.rm =TRUE), Med =median(cm, na.rm =TRUE), Max =max(cm, na.rm =TRUE),StDev =sd(cm, na.rm =TRUE), SampleSize =n() ) %>%pander()
person
angle
Average
Min
Med
Max
StDev
SampleSize
Cali
sit
76.04
46.8
79.2
107.8
22.67
5
Cali
stand
46.72
12.2
61.5
72.6
30.63
5
Stephanie
sit
78.8
59.8
77
104.3
17.35
5
Stephanie
stand
63.64
15.3
69.4
107.6
39.2
5
The standard deviation on standing angle is crazy, but the averages appear much lower than sitting angle.
It looks like for the blocks, nearly every assumption has been violated. Normality has not been met, constant variance shows a megaphone type pattern, and the independence plot doesn’t look randomized, there may be trends.
Study: mm.aov2 ~ "Group"
Scheffe Test for cm
Mean Square Error : 822.312
Group, means
cm std r se Min Max Q25 Q50 Q75
Cali.sit 76.04 22.66833 5 12.82429 46.8 107.8 64.1 79.2 82.3
Cali.stand 46.72 30.62608 5 12.82429 12.2 72.6 14.9 61.5 72.4
Stephanie.sit 78.80 17.35036 5 12.82429 59.8 104.3 67.0 77.0 85.9
Stephanie.stand 63.64 39.19698 5 12.82429 15.3 107.6 32.6 69.4 93.3
Alpha: 0.05 ; DF Error: 16
Critical Value of F: 3.238872
Minimum Significant Difference: 56.53349
Means with the same letter are not significantly different.
cm groups
Stephanie.sit 78.80 a
Cali.sit 76.04 a
Stephanie.stand 63.64 a
Cali.stand 46.72 a
This scheffé test shows that each of these groups are not different for each other.
Interpretation
All in all I think this experiment was very silly and it didn’t lead to much significant results. This wasn’t my favorite or best design and I feel that if we had more blocks, more marshmallows we might have been able to see just more results that ultimately could have been significant.