---
title: "Homework 9"
subtitle: "Psychology 2812B FW22"
output: html_document
---

# Lab Component

We will be using some sample data from Matthew Crump's course, which is data from the following paper:

> Rosenbaum D, Mama Y, Algom D (2017) **Stand by Your Stroop: Standing Up Enhances Selective Attention and Cognitive Control**. *Psychol Sci 28:1864–1867*  
  Available at: [http://dx.doi.org/10.1177/0956797617721270](http://dx.doi.org/10.1177/0956797617721270)

Read over the description of the experiment provided in section 10.1.1 of [Matthew Crump's lab for Factorial ANOVA](https://crumplab.com/statisticsLab/lab-10-factorial-anova.html).

For this week's lab we will be treating the data as a between-subjects design, in other words, we will be assuming that different participants provided observations in each of the 4 groups.

## 1. Load the data

```{r}
# your code goes here
```


## 2. Visualize the data

Plot some histograms showing each group in the 2x2 design. Use the `facet_wrap()` function to create a 2x2 grid of plots. Here is an example (but it is only an example):

```{r}
# your code goes here
```

Compute means and standard errors for each group. Use `group_by()` and `summarise()` to create a new data frame with the means, standard errors, and n for each group.

```{r}
# your code goes here
```

Create a plot of your choosing showing mean RTs for each group with error bars indicating standard errors, and overlay the raw data points using `geom_jitter()`. Here is an example (but it is only an example):

```{r}
# your code goes here
```


## 3. Compute the ANOVA

Use `aov()` to compute a 2x2 factorial ANOVA for the data. Use `summary()` to print the results.

```{r}
# your code goes here
```

Interpret the results of the ANOVA. In particular, interpret the results of the two main effects tests and the interaction test. What do these results tell you about the effect of congruency and posture on RT? Use marginal means to describe the effects. Don't worry about doing post-hoc statistical tests yet (we will do that next week), just interpret the means.

```{r}
# your code goes here
```

> your text goes here


## 4. Check assumptions

### 4.1. Normality

Check the normality assumption by (a) a Q-Q plot of the residuals of the ANOVA model, and (b) using the Shapiro test on the residuals. Report and interpret the results.

```{r}
# your code goes here
```

> your text goes here


### 4.2 Homogeneity of variance

Check the homogeneity of variance assumption using `leveneTest()` from the `car` package. Report and interpret the results.

```{r}
# your code goes here
```

> your text goes here


# Home Component

## 1. Load the data

From a textbook by Maxwell & Delaney---A clinical psychologist is interested in three types of therapy for modifying snake phobia. However, she does not believe that one type is necessarily best for everyone; instead, the best type may depend on degree (i.e., severity) of phobia. Undergraduate students enrolled in an introductory psychology course are given the Fear Schedule Survey (FSS) to screen out subjects showing no fear of snakes. Those displaying some degree of phobia are classified as either mildly, moderately, or severely phobic on the basis of the FSS. One third of subjects within each level of severity are then assigned to a treatment condition: systematic desensitization, implosive therapy, or insight therapy. Thus this is a 2-way between subjects design, with 3 levels in each of the two factors. So this is a 3x3 between subjects design.

The following data are obtained, using the Behavioral Avoidance Test as the dependent variable (higher scores are better):

```{r, message=FALSE, warning=FALSE}
library(tidyverse)
snakes <- read_csv(url("https://www.gribblelab.org/2812/data/snakes_data.csv"), col_types="nff")
glimpse(snakes)
```

## 2. Compute means

Compute the mean, standard error, and sample size for each of the nine groups. Use `group_by()` and `summarise()` to create a new data frame with the means, standard errors, and n for each group.

```{r}
# your code goes here
```

## 3. Visualize the data

Generate a plot of your choosing showing mean BAT for each group with error bars indicating standard errors, and overlay the raw data points using `geom_jitter()`.

```{r}
# your code goes here
```

## 4. Compute the ANOVA

Use `aov()` to compute a 3x3 factorial ANOVA for the data. Use `summary()` to print the results.

```{r}
# your code goes here
```

Report the results of the ANOVA. In particular, report the results of the two main effects tests and the interaction test. What do these results tell you about the effect of Treatment and Phobia on BAT? Don't worry about doing post-hoc statistical tests yet (we will do that next week), just interpret the means.

> your text goes here


## 5. Check assumptions

### 5.1. Normality

Check the normality assumption by (a) a Q-Q plot of the residuals of the ANOVA model, and (b) using the Shapiro test on the residuals. Report and interpret the results.

```{r}
# your code goes here
```

> your text goes here


### 5.2 Homogeneity of variance

Check the homogeneity of variance assumption using `leveneTest()` from the `car` package. Report and interpret the results.

```{r}
# your code goes here
```

> your text goes here




