For this exercise, please try to reproduce the results from Experiment 6 of the associated paper (Shah, Shafir, & Mullainathan, 2015). The PDF of the paper is included in the same folder as this Rmd file.

Methods summary:

The authors were interested in the effect of scarcity on people’s consistency of valuation judgments. In this study, participants played a game of Family Feud and were given either 75 s (budget - “poor” condition) or 250 s (budget - “rich” condition) to complete the game. After playing the game, participants were either primed to think about a small account of time necessary to play one round of the game (account -“small” condition) or a large account (their overall time budget to play the entire game, account - “large” condition.) Participants rated how costly it would feel to lose 10s of time to play the game. The researchers were primarily interested in an interaction between the between-subjects factors of scarcity and account, hypothesizing that those in the budget - “poor” condition would be more consistent in their valuation of the 10s regardless of account in comparison with those in the budget - “rich” condition. The authors tested this hypothesis with a 2x2 between-subjects ANOVA.


Target outcomes:

Below is the specific result you will attempt to reproduce (quoted directly from the results section of Experiment 6):

“One participant was excluded because of a computer malfunction during the game. Time-rich participants rated the loss as more expensive when they thought about a small account (M = 8.31, 95% CI = [7.78, 8.84]) than when they thought about a large account (M = 6.50, 95% CI = [5.42, 7.58]), whereas time-poor participants’ evaluations did not differ between the small-account condition (M = 8.33, 95% CI = [7.14, 9.52]) and the large account condition (M = 8.83, 95% CI = [7.97, 9.69]). A 2 (scarcity condition) × 2 (account condition) analysis of variance revealed a significant interaction, F(1, 69) = 5.16, p < .05, ηp2 = .07.” (Shah, Shafir & Mullainathan, 2015) ——

Step 1: Load packages

library(tidyverse) # for data munging
library(knitr) # for kable table formating
library(haven) # import and export 'SPSS', 'Stata' and 'SAS' Files
library(readxl) # import excel files

# #optional packages:
library(afex) #anova functions
#library(langcog) #95 percent confidence intervals

Step 2: Load data

# Just Experiment 6
data <- read_excel("data/study 6-accessible-feud.xlsx")

Step 3: Tidy data

The data are already tidy as provided by the authors.

Step 4: Run analysis

Pre-processing

One participant was excluded because of a computer malfunction during the game (Shah, Shafir, & Mullainathan, 2015, p. 408)

Note: The original paper does not identify the participant that was excluded, but it was later revealed through communication with the authors that it was participant #16. The exclusion is performed below.

# Participant #16 should be dropped from analysis 
excluded <- "16"

d <- data %>%
  filter(!Subject %in% excluded) #participant exclusions

# wrangling 

dwr <- d %>%
  mutate(
    Condition = case_when(
      Cond == 0 & Slack == 0 & Large == 0 ~ "Time-rich, Small account",
      Cond == 1 & Slack == 1 & Large == 0 ~ "Time-poor, Small account",
      Cond == 2 & Slack == 0 & Large == 1 ~ "Time-rich, Large account",
      Cond == 3 & Slack == 1 & Large == 1 ~ "Time-poor, Large account"
    )
  )

Descriptive statistics

Time-rich participants rated the loss as more expensive when they thought about a small account (M = 8.31, 95% CI = [7.78, 8.84]) than when they thought about a large account (M = 6.50, 95% CI = [5.42, 7.58]), whereas time-poor participants’ evaluations did not differ between the small-account condition (M = 8.33, 95% CI = [7.14, 9.52]) and the large- account condition (M = 8.83, 95% CI = [7.97, 9.69]). (Shah, Shafir, & Mullainathan, 2015, p. 408)

#summarise 
dwr_summary <- dwr %>%
  group_by(Condition) %>%
  summarize(
    Mean = mean(expense, na.rm = TRUE),
    SD = sd(expense, na.rm = TRUE),
    N = n(),
    SEM = SD / sqrt(N),
    CI = qt(0.975, df = N-1) * SEM
  ) %>%
  mutate(
    CI_Lower = Mean - CI,
    CI_Upper = Mean + CI
  ) %>%
  ungroup()

kable(dwr_summary)
Condition Mean SD N SEM CI CI_Lower CI_Upper
Time-poor, Large account 6.500000 2.332633 18 0.5498069 1.1599911 5.340009 7.659991
Time-poor, Small account 8.312500 1.078193 16 0.2695482 0.5745285 7.737971 8.887028
Time-rich, Large account 8.833333 1.855041 18 0.4372373 0.9224901 7.910843 9.755823
Time-rich, Small account 8.333333 2.780887 21 0.6068393 1.2658447 7.067489 9.599178

Inferential statistics

A 2 (scarcity condition) × 2 (account condition) analysis of variance revealed a significant interaction, F(1, 69) = 5.16, p < .05, ηp2 = .07.

# reproduce the above results here
anova_results <- aov(expense ~ Condition, data = dwr)
summary(anova_results)
##             Df Sum Sq Mean Sq F value Pr(>F)  
## Condition    3   56.9  18.965    4.05 0.0103 *
## Residuals   69  323.1   4.683                 
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Step 5: Reflection

Were you able to reproduce the results you attempted to reproduce? If not, what part(s) were you unable to reproduce?

This was a step into a new way of working with R. I haven’t run ANOVA before, nor have I stored descriptive statistics in a dataframe. Now that I have this code as a boiler plate, I can easily replicate the process. I understood the data structure, even though there was no coding manual for the column headers. I got help from chatGPT, but not with identifying work flow. I used pseudocode and identified the preprocessing, descriptive, and analysis procedures on my own. I have very limited knowledge of R syntax.

What aspects made it difficult? What aspects made it easy?

The hardest part for me is getting code to run. I understand the underlying concepts and analyses we’re trying to replicate… getting them in R is another matter.