PSY460: Advanced Quantitative Methods

Week #9: Interaction Effects

Today, we’ll discuss what an interaction means, and we’ll run a linear model to test whether one exists. We’ll also have time to work in groups.

“Quiz”

  • What have you learned about interaction effects from the two assigned videos?
  • Write down 1-2 questions you have after watching the two videos.
  • Reflect on your contributions to writing R code with your group during the past week. Approximately what percent did you contribute? If it was more or less than 33%, explain why. How well do you feel you understand the code that you submitted last night?

What is an interaction?

  • Interactions occur when a relationship between two variables depends on the value of a third variable.
  • This is most clearly indicated by non-parallel lines in a graph.

Research question

Do people update their judgments of whether somebody is a good cooperative partner more readily when they strongly endorse the moral value that was violated, and is this true only in cases of hypocrisy?

Getting ready for today’s analyses

#
library(tidyverse) # This gives us access to dplyr and ggplot. 
library(magrittr) # This allows us to use the double pipe.
library(ggthemes) # This allows us to use a minimal theme.
library(wesanderson) # This gives access to some nice color palettes.

TidyData <- read.csv('TidyData.csv', header = TRUE,
                     stringsAsFactors = FALSE) # Here's the data we'll use.

TidyData %<>% mutate(GoodCoopPartnerChange = 
                       as.numeric(rowMeans(
                         select(., c(IntegrityChange:FutureBehChange)))))

Checking variable structure

str(TidyData$ValueDiff)
 int [1:2044] 1 4 -5 3 6 -10 -10 -10 2 6 ...
str(TidyData$Condition)
 chr [1:2044] "Lapse" "Lapse" "NoLapse" "NoLapse" "Lapse" "NoLapse" "Lapse" ...
TidyData$Condition <- factor(TidyData$Condition, 
                             levels = c("Lapse", "NoLapse"), 
                             labels = c("Lapse", "No Lapse"), 
                             ordered = FALSE)

Testing for interactions visually

#
Fig <- ggplot(TidyData, aes(x = ValueDiff, y = GoodCoopPartnerChange, 
                            fill = Condition, color = Condition)) + 
  geom_jitter(width = .4, height = .4, alpha = .25, shape = 16) +
  geom_smooth(method = "lm", se = TRUE, linetype = 1) +
  labs(x = "Relative Prioritization of Baseline Value", 
       y = "Change in Evaluation of Partner Potential") +
  facet_wrap( ~ Condition) +
  theme_minimal() +
  scale_color_manual("Condition", values = wes_palette("Royal1")) +
  scale_fill_manual("Condition", values = wes_palette("Royal1"))

Testing for interactions visually

Testing for interactions statistically

# 
summary(lm(GoodCoopPartnerChange ~ ValueDiff*Condition, data = TidyData))

Testing for interactions statistically


Call:
lm(formula = GoodCoopPartnerChange ~ ValueDiff * Condition, data = TidyData)

Residuals:
     Min       1Q   Median       3Q      Max 
-21.0504  -1.4787   0.3325   2.0823  17.9496 

Coefficients:
                            Estimate Std. Error t value Pr(>|t|)    
(Intercept)                 -1.35936    0.11430 -11.893   <2e-16 ***
ValueDiff                   -0.24097    0.02001 -12.042   <2e-16 ***
ConditionNo Lapse            1.40978    0.16162   8.723   <2e-16 ***
ValueDiff:ConditionNo Lapse  0.03241    0.02829   1.146    0.252    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 3.652 on 2040 degrees of freedom
Multiple R-squared:  0.1402,    Adjusted R-squared:  0.1389 
F-statistic: 110.9 on 3 and 2040 DF,  p-value: < 2.2e-16

Re-running the model to examine main effects

# 
summary(lm(GoodCoopPartnerChange ~ ValueDiff + Condition, data = TidyData))

Testing for interactions statistically


Call:
lm(formula = GoodCoopPartnerChange ~ ValueDiff + Condition, data = TidyData)

Residuals:
     Min       1Q   Median       3Q      Max 
-20.8854  -1.4994   0.3482   2.1463  17.9482 

Coefficients:
                  Estimate Std. Error t value Pr(>|t|)    
(Intercept)       -1.36220    0.11428  -11.92   <2e-16 ***
ValueDiff         -0.22476    0.01415  -15.89   <2e-16 ***
ConditionNo Lapse  1.41397    0.16159    8.75   <2e-16 ***
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 3.653 on 2041 degrees of freedom
Multiple R-squared:  0.1396,    Adjusted R-squared:  0.1388 
F-statistic: 165.6 on 2 and 2041 DF,  p-value: < 2.2e-16

Looking ahead

  • Week #9 (this week): work on graphs
    • Need to reschedule meeting with Learning Curve
  • Week #10: finish analyzing your data
    • Need to reschedule meetings with other groups
  • Week #11: write up your findings and complete self-assessment
  • Week #12: work on presenting your findings
  • Week #13: research symposium

Plan for April 14: Individual Meetings

  • 1:00-1:15: Tian
  • 1:15-1:30: Katie
  • 1:30-1:45: Katherine
  • 1:45-2:00: Gonzalo
  • 2:00-2:15: Hannah
  • 2:15-2:30: Yosuke
  • 2:30-2:45: Brianna
  • 2:45-3:00:Annaliese
  • 3:15-3:30: Kyle
  • 3:30-3:45:Ayako
  • 3:45-4:00: Josh
  • 4:00-4:15: Jake

What visualizations would be useful for your team to create?