---
title: "Homework 7"
subtitle: "Psychology 2812B FW23"
output: html_document
---

# Lab Component

Like in the previous homework, we will again look at a dataset (from [https://pnb.mcmaster.ca/bennett/psy710](https://pnb.mcmaster.ca/bennett/psy710)) in which a dependent variable called "score" was measured in 4 groups of participants. Let's pretend that score is each participant's score on a memory test and condition is four different drugs they ingested prior to the memory test. We want to know if the drugs affect memory.

Load the view the dataset:

```{r,echo=TRUE,messages=FALSE,warning=FALSE}
library(tidyverse)
load(file=url('https://www.gribblelab.org/2812/data/theAOVdataRL3.rda'))
glimpse(theAOVdata)
```

1. Fit the ANOVA model to the data

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

2. Conduct post-hoc tests to determine which groups are different from each other. Use the Bonferroni correction to adjust for multiple comparisons.

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

3. Interpret the tests---which groups are different from each other? What do the p-values mean?

> your text goes here


# Home Component

4. Again conduct post-hoc tests to determine which groups are different from each other, but this time use the Bonferroni-Holm correction to adjust for multiple comparisons.

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

5. Interpret the tests---which groups are different from each other? What do the p-values mean?

> your text goes here

6. You are planning a new experiment that will involve 6 groups of participants. Your task is to estimate the sample size that you will need for each group in order to detect a difference in the mean of a dependent variable with a power of 0.80. You plan to adopt an alpha level of 0.05 for rejecting the null hypothesis. Based on pilot studies and other similar studies reported in the literature, you estimate that the within-group variance will be 5 times larger than the between-groups variance. Use `power.anova.test()` to estimate the sample size needed for each group. Round up to the nearest whole number. How many participants will be needed for the whole experiment?

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

> your text goes here


7. Let's say you go ahead and run the experiment described above in Q6.

a. Define Type-I error

> your text goes here

b. If the null hypothesis is true and there actually isn't a difference in the mean of the dependent variable across groups in the population, what is the probability that you will make a Type-I error?

> your text goes here

c. What could you do to reduce the probability of making a Type-I error?

> your text goes here

d. Define Type-II error

> your text goes here

e. If the null hypothesis is false and there actually is a difference in the mean of the dependent variable across groups in the population, what is the probability that you will make a Type-II error?

> your text goes here

f. What could you do to reduce the probability of making a Type-II error?

> your text goes here




