Homework 9

Psychology 2812B FW22

Weekly homework assignments are comprised of two components: a Lab Component that your TA will guide you through in the weekly lab session, and a Home Component that you are to complete on your own. You must hand in both components. Both will count towards your grade.

Submit homework on OWL by 5:00 pm London ON time on the date shown in the Class Schedule.

Submit your homework assignment as a single RMarkdown file, using your last name and the homework assignment as a filename in the following format: gribble_n.Rmd where n is the homework assignment number.

Here is the R Markdown template file for this assignment: lastname_9.Rmd.


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

Read over the description of the experiment provided in section 10.1.1 of Matthew Crump’s lab for Factorial ANOVA.

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

library(tidyverse)
Warning: package 'lubridate' was built under R version 4.3.1
stroop <- read_csv(url("https://www.gribblelab.org/2812/data/stroop_df.csv"), col_types="iffn")
glimpse(stroop)
Rows: 200
Columns: 4
$ Subject    <int> 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, …
$ Congruency <fct> Congruent, Congruent, Congruent, Congruent, Congruent, Cong…
$ Posture    <fct> Stand, Stand, Stand, Stand, Stand, Stand, Stand, Stand, Sta…
$ RT         <dbl> 892.1429, 701.6111, 1009.7419, 734.6286, 904.8529, 955.9118…

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):

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.

# A tibble: 4 × 5
# Groups:   Congruency [2]
  Congruency  Posture meanRT    se     n
  <fct>       <fct>    <dbl> <dbl> <int>
1 Congruent   Stand     808.  14.9    50
2 Congruent   Sit       822.  16.6    50
3 Incongruent Stand     904.  15.3    50
4 Incongruent Sit       941.  17.9    50

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):

3. Compute the ANOVA

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

                    Df  Sum Sq Mean Sq F value   Pr(>F)    
Congruency           1  576822  576822  43.734 3.49e-10 ***
Posture              1   32303   32303   2.449    0.119    
Congruency:Posture   1    6560    6560   0.497    0.481    
Residuals          196 2585080   13189                     
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

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 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.

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.


    Shapiro-Wilk normality test

data:  residuals(my.anova)
W = 0.98681, p-value = 0.05967

4.2 Homogeneity of variance

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

Levene's Test for Homogeneity of Variance (center = median)
       Df F value Pr(>F)
group   3  0.5212 0.6682
      196               

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):

library(tidyverse)
snakes <- read_csv(url("https://www.gribblelab.org/2812/data/snakes_data.csv"), col_types="nff")
glimpse(snakes)
Rows: 45
Columns: 3
$ BAT       <dbl> 14, 17, 10, 13, 12, 15, 11, 12, 10, 9, 12, 10, 10, 9, 11, 10…
$ Treatment <fct> Desensitization, Desensitization, Desensitization, Desensiti…
$ Phobia    <fct> Mild, Mild, Mild, Mild, Mild, Moderate, Moderate, Moderate, …

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.

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().

4. Compute the ANOVA

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

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.

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.

5.2 Homogeneity of variance

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