\clearpage

# PREPARATION

```{r oppts, include=FALSE}
# set global chunk options...  
#  this changes the defaults so you don't have to repeat yourself
knitr::opts_chunk$set(comment     = NA,
                      cache       = TRUE,
                      echo        = TRUE, 
                      warning     = FALSE, 
                      message     = FALSE,
                      fig.align   = "center", # center all figures
                      fig.width   = 5,        # set default figure width to 5 inches
                      fig.height  = 3)        # set default figure height to 3 inches

```



## Packages

Make sure the packages are **installed** *(Package tab)*

```{r libraries, error = FALSE}
library(magrittr)
library(tidyverse)    # Loads several very helpful 'tidy' packages
library(readxl)       # Read in Excel datasets
library(furniture)    # Nice tables (by our own Tyson Barrett)
library(afex)         # Analysis of Factorial Experiments
library(emmeans)      # Estimated marginal means (Least-squares means)
library(pander)       # Formats tables 
```

\clearpage



# SECTION B

## Datasets

```{r data}
memory_wide <- data.frame(id = 1:6,
                          digit  = c(6, 8, 7, 8, 6, 7),
                          letter = c(5, 7, 7, 5, 4, 6),
                          mixed  = c(6, 5, 4, 8, 7, 5)) %>% 
  dplyr::mutate(id = factor(id))


caffiene_wide <- data.frame(block  = 1:6,
                           mg_0   = c(25, 19, 22, 15, 16, 20),
                           mg_100 = c(16, 15, 19, 11, 14, 23),
                           mg_200 = c( 6, 14,  9,  5,  9, 11),
                           mg_300 = c( 8, 18,  9, 10, 12, 13)) %>% 
  dplyr::mutate(block = factor(block))


audience_wide <- data.frame(id     = 1:12,
                            one    = c(131, 109, 115, 110, 107, 111, 
                                       100, 115, 130, 118, 125, 135),
                            twenty = c(130, 124, 110, 108, 115, 117, 
                                       102, 120, 119, 122, 118, 130),
                            large  = c(135, 126, 108, 122, 111, 121, 
                                       107, 132, 128, 130, 133, 135))%>% 
  dplyr::mutate(id = factor(id))

textbook_wide <- data.frame(block = 1:9,
                            A = c(17,  8,  6, 12, 19, 14, 10,  7, 12),
                            B = c(15,  6,  5, 10, 20, 13,  7,  7, 11),
                            C = c(20, 11, 10, 14, 20, 15, 14, 11, 15),
                            D = c(18,  7,  6, 13, 18, 15, 10,  6, 13))%>% 
  dplyr::mutate(block = factor(block))
```

\clearpage



## `memory_wide`

```{r}
memory_wide
```


### Restructure from wide to long format

```{r}
memory_long <- memory_wide %>% 
  tidyr::pivot_longer(cols = c(digit, letter, mixed),
                      names_to = "stimuli",
                      names_ptypes = list(stimuli = factor()),
                      values_to = "recall")

psych::headTail(memory_long)
```

### Person-Profile Plot

```{r}
memory_long %>% 
  ggplot(aes(x = stimuli,
             y = recall,
             group = id,
             linetype = id)) +
  geom_point()+
  geom_line() + 
  theme_bw() +
  labs(x = "Type of Stimuli",
       y = "Short Term Memory, Number Recalled",
       linetype = "Participant")
```

### 15A-2 Visual examination of Interaction: Sub x RM

Describe the degree of interaction between the various pairs of levels. 


\clearpage

## `caffiene_wide`

```{r}
caffiene_wide
```



### Restructure from wide to long format

```{r}
caffiene_long <- caffiene_wide %>% 
  tidyr::pivot_longer(cols = c(mg_0, mg_100, mg_200, mg_300),
                      names_to = "dose",
                      names_prefix = "mg_",
                      names_ptypes = list(dose = factor()),
                      values_to = "errors")

psych::headTail(caffiene_long)
```

### Person-Profile Plot

```{r}
caffiene_long %>% 
  ggplot(aes(x = dose,
             y = errors,
             group = block,
             linetype = block)) +
  geom_point()+
  geom_line() +
  theme_bw() +
  labs(x = "Dose of Caffiene, mg",
       y = "Video Game: Number of Errors",
       linetype = "Block of\nMatched\nParticipants")
```

### 15A-5a Visual examination of Interaction: Sub x RM



\clearpage

## `audience_wide` - Repeated Measures Design: Effect of Audience Size on Blood Pressure

**TEXTBOOK QUESTION:** *A psychophysiologist wishes to explore the effects of public speaking on the systolic blood pressure of young adults. Three conditions are tested. The subject must vividly imagine delivering a speech to one person, to a small class of 20 persons, or to a large audience consisting of hundreds of fellow students. Each subject has his or her systolic blood pressure measured (mmHg) under all three conditions. Two subjects are randomly assigned to each of the six possible treatment orders. The data appear in the following table:*

```{r, echo=FALSE}
audience_wide
```


### Restructure from wide to long format

```{r, echo=FALSE}
# Restructure: wide-to-long
audience_long <- audience_wide %>% 
  tidyr::pivot_longer(cols = c(one, twenty, large),
                      names_to = "audience",
                      names_ptypes = list(audience = factor()),
                      values_to = "blood_pressure") 
```


```{r, echo=FALSE}
psych::headTail(audience_long)
```

\clearpage



### Summary Statistics

```{r, echo=FALSE, results="asis"}
# Raw data: summary table
audience_long %>% 
  dplyr::group_by(audience) %>%             # divide into groups
  furniture::table1(blood_pressure,         # gives M(SD)
                    digits = 2,
                    output = "markdown")    # add chunk option: results="asis"
```



### Person-Profile Plot

```{r, echo=FALSE}
audience_long %>% 
  ggplot(aes(x = audience,
             y = blood_pressure,
             group = id,
             color = id,
             shape = id)) +
  geom_point() +
  geom_line() +
  theme_bw() +
  theme_bw() +
  labs(x = "Size of Audience Imagined",
       y = "Systolic Blood Pressure, mmHg")
```



### Means Plot: M $\pm$ SEM

```{r, echo=FALSE}
audience_long %>% 
  ggplot(aes(x = audience,
             y = blood_pressure,
             group = 1)) +
  stat_summary() +
  stat_summary(fun.y = mean,
               geom = "line") +
  theme_bw() +
  labs(x = "Size of Audience Imagined",
       y = "Systolic Blood Pressure, mmHg")
```

\clearpage



### 15B-3a/b/c RM ANOVA: no sphericity correction, but both effect sizes

**TEXTBOOK QUESTION:** *(a) Perform an RM ANOVA on the blood pressure data and write the results in words, as they would appear in a journal article. Does the size of the audience have a significant effect on blood pressure at the .05 level? ~~(Hint : Subtract 100 from every entry in the preceding table before computing any of the SS's. This will make your work easier without changing any of the SS components or F ratios.)~~  (b) What might you do to minimize the possibility of carryover effects?*




**DIRECTIONS:** Perform a Repeated Measures ANOVA for blood pressure under the three condiditons to determine if the size of the imagine audience has an effect.  Request no correction for violations of sphericity (`correction = "none"`) and both effect sizes (`es = c("ges", "pes")`).  Save this model as a name `fit_audience`.

```{r}
# RM ANOVA: no correction for lack of sphericity  <-- NAME AND SAVE

```

**DIRECTIONS:** Run the name (without `$Anova`, `$aov` or `summary()`) to see the brief output.

```{r}

```



\clearpage



### 15B-3c RM ANOVA: display all Sums-of-Squares components

**TEXTBOOK QUESTION:** *(c) Calculate $\eta_{RM}^2$ from the F ratio you calculated in part a. Does this look like a large effect? How could this effect size be misleading in planning future experiments?*

**DIRECTIONS:** Request all the Sums-of-Squares (SS's) by adding `$aov` at the end of the model name `fit_audience`.

```{r}
# RM ANOVA: display all Sums-of-Squares components

```

\clearpage



### 15B-3d RM ANOVA: post hoc with Fisher's LSD correction

**TEXTBOOK QUESTION:** *(d) Test all the pairs of means with protected t tests using the error term from the RM ANOVA. Which pairs differ significantly at the .01 level?*

**DIRECTIONS:** Conduct all possible post hoc pairwise tests on `fit_audience` using Fisher's LSD.

```{r}
# RM ANOVA: post hoc all pairwise tests with Fisher's LSD correction

```

-----------------------

**Means Plot (model based)**

**DIRECTIONS:** Construct a means plot of `fit_audience` using `emmeans::emmip(~ RM_var)` to help interpret the direction of any significant differences.  Include the option for the confidence intervals by adding the option `CIs = TRUE`.

```{r}
# RM ANOVA: means plot

```

\clearpage



## `textbook_wide` - Matched Design: Effect of Textbook on Student Quiz Scores

**TEXTBOOK QUESTION:** *A statistics professor wants to know if it really matters which textbook she uses to teach her course. She selects four textbooks that differ in approach and then matches her 36 students into blocks of four based on their similarity in math background and aptitude. Each student in each block is randomly assigned to a different text. At some point in the course, the professor gives a surprise 20-question quiz. The number of questions each student answers correctly appears in the following table:*

```{r, echo=FALSE}
textbook_wide
```

### Restructure from wide to long format

```{r, echo=FALSE}
# Restructure: wide-to-long
textbook_long <- textbook_wide %>% 
  tidyr::pivot_longer(cols = c("A", "B", "C", "D"),
                      names_to = "book",
                      names_ptypes = list(book = factor()),
                      values_to = "quiz") %>% 
  dplyr::mutate(id = paste(block, book, sep = "_"))
```


```{r, echo=FALSE}
psych::headTail(textbook_long)
```

\clearpage



### Summary Statistics

```{r, echo=FALSE, results="asis"}
# Raw data: summary table
textbook_long %>% 
  dplyr::group_by(book) %>%                 # divide into groups
  furniture::table1(quiz,                   # gives M(SD)
                    digits = 2,
                    output = "markdown")    # add chunk option: results="asis"
```



### Person-Profile Plot

```{r, echo=FALSE}
textbook_long %>% 
  ggplot(aes(x = book,
             y = quiz,
             group = block,
             shape = block,
             color = block)) +
  geom_point() +
  geom_line() +
  theme_bw() +
  labs(x = "Textbook",
       y = "Quiz Score")
```



### Means Plot: M $\pm$ SEM

```{r, echo=FALSE}
textbook_long %>% 
  ggplot(aes(x = book,
             y = quiz,
             group = 1)) +
  stat_summary() +
  stat_summary(fun.y = mean,
               geom = "line") +
  theme_bw() + 
  labs(x = "Textbook",
       y = "Quiz Score, mean")
```

\clearpage



### 15B-4a RM ANOVA: display all Sums-of-Squares components

**TEXTBOOK QUESTION:** *(a) Perform an RM ANOVA on the data, and present the results of your ANOVA in a summary table. Does it make a difference which textbook the professor uses?  (b) Considering your answer to part a, what type of error could you be making (Type I or Type II)?*

**DIRECTIONS:** Perform a Repeated Measures ANOVA for quiz scores under the four books to determine if the text has an effect.  Make sure to save your model (`fit_textbook`).

```{r}
# RM ANOVA: display all Sums-of-Squares components

```

**DIRECTIONS:** Add `$aov` at the end of the name to extract all the Sums-of-Squares.

```{r}

```



\clearpage



### 15B-4c RM ANOVA: GG correction for lack of sericity

**TEXTBOOK QUESTION:** *(c) Would your F ratio from part a be significant at the .01 level if you were to assume a maximum violation of the sphericity assumption? Explain. *

**DIRECTIONS:** Run the name of the model `fit_textbook` alone to extract the adjusted degrees of freedom and F-test.  The sums-of-squares for the corrected test are the same as for the uncorrected you just did.

```{r}
# RM ANOVA: GG correction for lack of sphericity

```

\clearpage



### 15B-4d RM ANOVA: post-hoc with Tukey's HSD correction

**TEXTBOOK QUESTION:** *(d) Test all the pairs of means with Tukey's HSD, using the error term from the RM ANOVA. Which pairs differ significantly at the .05 level?*

**DIRECTIONS:** Conduct all possible post hoc pairwise tests on `fit_audience` using Tukey's HSD.

```{r}
# RM ANOVA: post hoc all pairwise tests with Tukey's HSD correction

```

------------------

**Means Plot (model based)**

**DIRECTIONS:** Construct a means plot of `fit_audience` using `emmeans::emmip(~ RM_var)` to help interpret the direction of any significant differences. Include the option for the confidence intervals by adding the option `CIs = TRUE`.

```{r}

```

\clearpage

### 15B-5a 1-Way ANOVA (treat students as independent)

**TEXTBOOK QUESTION:** *(a) Perform a one-way independent-groups ANOVA on the data from Exercise 4.*

**DIRECTIONS:** Perform the ANOVA with the `book` as an between-subjects factor, instead of a within-subjects factor (ignoring matching) for quiz scores to determine if the text has an effect.  Make sure to save your model (`fit_book1way`).

```{r}
# 1-way ANOVA: 1 between-subject factor

```

**DIRECTIONS:** Add `$aov` at the end of the model name to get the Sum-of-Squares and degrees of freedom.

```{r}

```





-------------------------------

**TEXTBOOK QUESTION:** *(b) Does choice of text make a significant difference when the groups of subjects are considered to be independent (i.e., the matching is ignored)? (c) Comparing your solution to this exercise with your solution to Exercise 4, which part of the F ratio remains unchanged? What can you say about the advantages of matching in this case?*

\clearpage



## `memory_wide` - Repeated Measures Design: Stimuli's Effect on Memory Recall

**TEXTBOOK QUESTION:** *A neuropsychologist is exploring short-term memory deficits in people who have suffered damage to the left cerebral hemisphere. He suspects that memory for some types of material will be more affected than memory for other types. To test this hypothesis he presented six brain-damaged subjects with stimuli consisting of strings of digits, strings of letters, and strings of digits and letters mixed. The longest string that each subject in each stimulus condition could repeat correctly is presented in the following table. (One subject was run in each of the six possible orders.)* 

```{r, echo=FALSE}
memory_wide
```

### Restructure from wide to long format

```{r, echo=FALSE}
# Restructure: wide-to-long
memory_long <- memory_wide %>% 
  tidyr::pivot_longer(cols = c(digit, letter, mixed),
                      names_to = "stimuli",
                      names_ptypes = list("stimuli" = factor()),
                      values_to = "recall")
```


```{r, echo=FALSE}
psych::headTail(memory_long)
```

\clearpage



### Summary Statistics

```{r, echo=FALSE, results="asis"}
# Raw data: summary table
memory_long %>% 
  dplyr::group_by(stimuli) %>%                 # divide into groups
  furniture::table1(recall,                   # gives M(SD)
                    digits = 2,
                    output = "markdown")    # add chunk option: results="asis"
```



### Person-Profile Plot

```{r, echo=FALSE}
memory_long %>% 
  ggplot(aes(x = stimuli,
             y = recall,
             group = id,
             shape = id,
             color = id)) +
  geom_point() +
  geom_line() +
  theme_bw() +
  labs(x = "Type of Stimuli",
       y = "Recall")
```



### Means Plot: M $\pm$ SEM

```{r, echo=FALSE}
memory_long %>% 
  ggplot(aes(x = stimuli,
             y = recall,
             group = 1)) +
  stat_summary() +
  stat_summary(fun.y = mean,
               geom = "line") +
  theme_bw() +
  labs(x = "Type of Stimuli",
       y = "Mean Recall")
```

\clearpage



### 15B-6a RM ANOVA: with sphericity test and corrections

**TEXTBOOK QUESTION:** *(a) Perform an RM ANOVA. Is your calculated F value significant at the .05 level?*

**DIRECTIONS:** Perform a Repeated Measures ANOVA for recall under the three stimuli to determine if the type of stimuli has an effect. Save it as the name `fit_memory`. 

```{r}
# RM ANOVA: Mauchle Tests for Sphericity and Corrections applied

```


**DIRECTIONS:** Use the `summary()` function display additional output.

```{r}

```



\clearpage



### 15B-6b RM ANOVA: GG corretion for lack of sphericity

**TEXTBOOK QUESTION:** *(b) Would your conclusion in part a change if you could not assume that sphericity exists in the population underlying this experiment? Explain. (c) Based on the graph you drew of these data for Exercise 15A2, would you say that the RM ANOVA is appropriate for these data? Explain.*

**DIRECTIONS:** Run the name of the model `fit_memory` alone to extract the adjusted degrees of freedom and F-test.  The sums-of-squares for the corrected test are the same as for the uncorrected you just did.

```{r}
# RM ANOVA: GG correction for lack of sphericity

```

\clearpage



### 15B-6d RM ANOVA: post-hoc with Fisher's LDS correction

**TEXTBOOK QUESTION:** *(d) Test all the possible pairs of means with separate matched t tests (or two-group RM ANOVAs) at the .01 level.*

**DIRECTIONS:** Conduct all possible post hoc pairwise tests on `fit_memory` using Fisher's LSD.

```{r}
# RM ANOVA: post hoc all pairwise tests with Fisher's LSD correction

```

--------------

**Means Plot (model based)**

**DIRECTIONS:** Construct a means plot of `fit_audience` using `emmeans::emmip(~ RM_var)` to help interpret the direction of any significant differences. Include the option for the confidence intervals by adding the option `CIs = TRUE`.

```{r}
# RM ANOVA: means plot

```

\clearpage



# SECTION C

## Import Data, Define Factors, and Compute New Variables

Import Data, Define Factors, and Compute New Variables

* Make sure the **dataset** is saved in the same *folder* as this file
* Make sure the that *folder* is the **working directory**

> NOTE: I added the second line to convert all the variables names to lower case.  I still kept the `F` as a capital letter at the end of the five factor variables.

```{r ihno}
ihno_clean <- read_excel("Ihno_dataset.xls") %>% 
  dplyr::rename_all(tolower) %>% 
  dplyr::mutate(genderF = factor(gender, 
                                 levels = c(1, 2),
                                 labels = c("Female", 
                                            "Male"))) %>% 
  dplyr::mutate(majorF = factor(major, 
                                levels = c(1, 2, 3, 4,5),
                                labels = c("Psychology",
                                           "Premed",
                                           "Biology",
                                           "Sociology",
                                           "Economics"))) %>% 
  dplyr::mutate(reasonF = factor(reason,
                                 levels = c(1, 2, 3),
                                 labels = c("Program requirement",
                                            "Personal interest",
                                            "Advisor recommendation"))) %>% 
  dplyr::mutate(exp_condF = factor(exp_cond,
                                   levels = c(1, 2, 3, 4),
                                   labels = c("Easy",
                                              "Moderate",
                                              "Difficult",
                                              "Impossible"))) %>% 
  dplyr::mutate(coffeeF = factor(coffee,
                                 levels = c(0, 1),
                                 labels = c("Not a regular coffee drinker",
                                            "Regularly drinks coffee")))  %>% 
  dplyr::mutate(hr_base_bps = hr_base / 60) 
```

\clearpage



## `ihno_clean` - Repeated Measures Design: Effect of Time (expereiment) on Anxiety levels (performed INDEPENDENTLY by GENDER)

**TEXTBOOK QUESTION:** *(a) Use Split File to perform separate RM ANOVAs for men and women to test for a significant change in anxiety level over time (baseline, prequiz, and postquiz). Use Options to request pairwise tests. Write up the results in APA style.*



```{r}
ihno_clean %>% 
  dplyr::select(sub_num, anx_base, anx_pre, anx_post) %>% 
  head(n = 4)
```

### Restructure from wide to long format

```{r}
#Restructure: wide-to-long
ihno_anx_long <- ihno_clean %>% 
  tidyr::pivot_longer(cols = c(anx_base, anx_pre, anx_post),
                      names_to = "time",
                      names_ptypes = list(time = factor()),
                      names_prefix = "anx_",
                      values_to = "anxiety") 
```    



```{r}
ihno_anx_long %>% 
  dplyr::select(sub_num, time, anxiety) %>% 
  head(n = 12)
```

\clearpage

### 15C-1a RM ANOVA (twice): with sphericity test and corrections 


**RESTRICT to just FEMALES** 

**DIRECTIONS:** Perform a Repeated Measures ANOVA for anxiety at all three time points to determine if the experiment had an effect. Make sure to preceed the ANOVA with a `dplyr::filter()` step to restrict to just `genderF == "Female`.  Save it as the name `fit_anx_female`. 

```{r}
# RM ANOVA: Mauchle Tests for Sphericity with and without corrections applied

```

**DIRECTIONS:** Use the `summary()` function display additional output.

```{r}

```

\clearpage



**DIRECTIONS:** If, and only if, the omnibus F test yielded evidence of at least one time point having a different average anxiety FOR WOMEN, follow up with post hoc pairs tests based on the ANOVA model.

```{r} 
# RM ANOVA: post hoc all pairwise tests with Fisher's LSD correction

```

----------------------

**Means Plot (model based)**

**DIRECTIONS:** If, and only if, the omnibus F test yielded evidence of at least one time point having a different average anxiety FOR WOMEN construct a means plot of `fit_audience` using `emmeans::emmip(~ RM_var)` to help interpret the direction of any significant differences. Include the option for the confidence intervals by adding the option `CIs = TRUE`.

```{r}
# Means Plot: model based

```

\clearpage



**RESTRICT to just MALES** 

**DIRECTIONS:** Perform a Repeated Measures ANOVA for anxiety at all three time points to determine if the experiment had an effect. Make sure to preceed the ANOVA with a `dplyr::filter()` step to restrict to just `genderF == "Male`.  Save it as the name `fit_anx_male`.

```{r} 
# RM ANOVA: Mauchle Tests for Sphericity with and without corrections applied

```

**DIRECTIONS:** Use the `summary()` function display additional output.

```{r}

```

\clearpage



**DIRECTIONS:** If, and only if, the omnibus F test yielded evidence of at least one time point having a different average anxiety FOR MEN, follow up with post hoc pairs tests based on the ANOVA model.

```{r} 
# RM ANOVA: post hoc all pairwise tests with Fisher's LSD correction

```

----------------------

**Means Plot (model based)**

**DIRECTIONS:** If, and only if, the omnibus F test yielded evidence of at least one time point having a different average anxiety FOR MEN, construct a means plot of `fit_audience` using `emmeans::emmip(~ RM_var)` to help interpret the direction of any significant differences. Include the option for the confidence intervals by adding the option `CIs = TRUE`.

```{r}
# Means Plot: model based

```

\clearpage



### 15C-1b Paired t-Tests: choose 2 at a time

**TEXTBOOK QUESTION:** *(b) Using ANALYZE/Compare Means , perform matched t tests for each pair of RM levels, and then compare these p values to those produced in the Pairwise Comparisons results box of the RM ANOVA.*

**DIRECTIONS:** If, and only if, the omnibus F test yielded evidence of at least one time point having a different average anxiety FOR WOMEN, follow up with post hoc pairs tests NOT based on the ANOVA model.  Instead, increase your `dplyr::filter()` to include requiring only 2 of the 3 time points (eg. `time %in% c("baseline", "pre-quiz")`).  You will have to do this 3 times, as there are three ways to choose a pair from three options.

```{r}
# Paired T-test: filter - women & baseline/pre-quiz
ihno_anx_long %>%
  dplyr::filter(genderF == "Female") %>%
  dplyr::filter(time %in% c("base", "pre")) %>%
  t.test(anxiety ~ time, data = ., paired = TRUE)
```



```{r}
# Paired T-test: filter - women & baseline or post-quiz

```



```{r}
# Paired T-test: filter - women & pre-quiz/post-quiz

```

\clearpage



**DIRECTIONS:** If, and only if, the omnibus F test yielded evidence of at least one time point having a different average anxiety FOR MEN, follow up with post hoc pairs tests NOT based on the ANOVA model.  Instead, increase your `dplyr::filter()` to include requiring only 2 of the 3 time points (eg. `time %in% c("baseline", "pre-quiz")`).  You will have to do this 3 times, as there are three ways to choose a pair from three options.

```{r}
# Paired T-test: filter - men & baseline/pre-quiz

```



```{r}
# Paired T-test: filter - men & baseline or post-quiz

```



```{r}
# Paired T-test: filter - men & pre-quiz/post-quiz

```

\clearpage



## `ihno_clean` - Repeated Measures Design: Effect of experiemnt (with vs without the experimental item) on Stat Quiz

**TEXTBOOK QUESTION:** *Perform an RM ANOVA to determine whether there is a significant difference in mean scores between the experimental stats quiz and the regular stats quiz. Compare this F ratio with the matched t value you obtained from computer exercise #3 in Chapter 11.*



```{r}
ihno_clean %>% 
  dplyr::select(sub_num, statquiz, exp_sqz) %>% 
  head(n = 5)
```

### Restructure from wide to long format

```{r}
ihno_statquiz_long <- ihno_clean %>% 
  tidyr::pivot_longer(cols = c(statquiz, exp_sqz),
                      names_to = "quiz_type",
                      names_ptypes = list(time = factor()),
                      values_to = "quiz_score") %>% 
  dplyr::mutate(quiz_type = quiz_type %>% 
                  forcats::fct_recode("Regular" = "statquiz",
                                      "Experimental" = "exp_sqz"))
```


```{r}
ihno_statquiz_long %>% 
  dplyr::select(sub_num, quiz_type, quiz_score) %>% 
  head(n = 10)
```

\clearpage

### 15C-3 RM ANOVA vs. Paired t-test: only 2 groups


**DIRECTIONS:** Perform a Repeated Measures ANOVA for recall under the three stimuli to determine if the type of stimuli has an effect. Do not save this model as a name; just run it **without** nameing/saving it.

> NOTE: When the measure is only repeated twice, sphericity can not be violated, so no such test are performed.

```{r}
# RM ANOVA: no correction for lack of sphericity 

```

-----------------------------

**DIRECTIONS:** Alternatively, since there are only two measures, you can run this same analysis as a paired t.test, using `t.test()`.  Make sure you include `paired = TRUE`.

```{r}
# Matched t-test: paired = TRUE

```


