# Load the mosaic package
library(tidyverse)
24 arachnophobe volunteers are randomly assigned to spend 10 minutes one of two rooms:
Click the tabs to see what’s in each room…
The room contains a real spider (in a cage).
The room contains only a photo of that same spider.
Click code
to see how the data were entered –>
# Enter the data manually
spider <- tibble(
group = c( rep("photo", 12), rep("real", 12) ),
anxiety = c(30, 35, 45, 40, 50, 35, 55, 25, 30, 45, 40, 50,
40, 35, 50, 55, 65, 55, 50, 35, 30, 50, 60, 39))
# Display some data (ordered by anxiety levels)
spider %>%
arrange(anxiety)
# Display summary statistics
spider %>%
group_by(group) %>%
summarize(mean = mean(anxiety),
median = median(anxiety),
sd = sd(anxiety),
n = n())
spider %>%
ggplot(aes(x = group, y = anxiety)) +
geom_dotplot(binaxis = "y", binpositions="all", stackdir = "center", fill = "steelblue", color = "white") +
scale_y_continuous(breaks=seq(20, 70, 10), minor_breaks=NULL) +
theme(axis.title.x = element_text(size = 12, color = "#777777")) +
theme(axis.text.x = element_text(size = 12)) +
theme(axis.title.y = element_text(size = 12, color="#777777")) +
theme(axis.text.y = element_text(size = 12)) +
labs(
title = "Anxiety by group"
)
spider %>%
ggplot(aes(y = anxiety, x = group)) +
geom_boxplot(fill = "white", color = "black", alpha = 0.9) +
geom_dotplot(binaxis = "y", stackdir = "center", fill = "steelblue", color = "white", alpha = 0.6) +
scale_y_continuous(breaks=seq(20, 70, 10), minor_breaks=NULL) +
theme(axis.title.x = element_text(size = 12, color = "#777777")) +
theme(axis.text.x = element_text(size = 12)) +
theme(axis.title.y = element_text(size = 12, color="#777777")) +
theme(axis.text.y = element_text(size = 12)) +
labs(
title = "Anxiety by group"
)
blah
Let’s construct a model that could have generated the data in this study. First, we’ll define:
• \(y_{ig}=\) the anxiety of subject i in group g
• \(\mu=\) a constant, overall mean anxiety level all humans possess
• \(\alpha _{g}=(\mu _{g}-\mu )=\) the change in anxiety associated with being assigned to group g
• \(\epsilon_{ig}=(y_{ig}-\mu _{g})=\) errors or deviations in anxiety among individuals in a group (due to other factors not analyzed in this study).
With this notation, we can write our full model: \(y_{ig}=\mu +\alpha _{g}+\epsilon_{ig}\).