# Load the tidyverse packages
library(tidyverse)

Scenario: Arachnophobia

24 arachnophobe volunteers are randomly assigned to spend 10 minutes one of two rooms:

–>

     Click the tabs to see what’s in each room…

blank

Room A

The room contains a real spider (in a cage).

real spider

Room B

The room contains only a photo of that same spider.

photo of spider

Does the real spider elicit more anxiety than the photo?



Data Exploration

     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)
#>   # A tibble: 24 × 2
#>      group anxiety
#>      <chr>   <dbl>
#>   1  photo      25
#>   2  photo      30
#>   3  photo      30
#>   4   real      30
#>   5  photo      35
#>   6  photo      35
#>   7   real      35
#>   8   real      35
#>   9   real      39
#>   10 photo      40
#>   # ... with 14 more rows

Summary statistics

# Display summary statistics

spider %>%
  group_by(group) %>%
  summarize(mean = mean(anxiety),
            median = median(anxiety),
            sd = sd(anxiety),
            n = n())
#>   # A tibble: 2 × 5
#>     group  mean median        sd     n
#>     <chr> <dbl>  <dbl>     <dbl> <int>
#>   1 photo    40     40  9.293204    12
#>   2  real    47     50 11.028888    12

Dotplot
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"
  )

Boxplot
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"
  )

.

  1. It appears as though the subjects with the real spider experienced greater anxiety. Explain why this does not prove the real spider elicits more anxiety than the photo of the spider.

blank


Model

  1. State the null and alternative hypotheses for this study

blank



  1. blah

blah

  1. 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}\).