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.
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.
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) ——
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
library(dplyr)
library(effectsize)
library(broom)
library(glue)
# #optional packages:
# library(afex) #anova functions
# library(langcog) #95 percent confidence intervals
# Just Experiment 6
data <- read_excel("data/study 6-accessible-feud.xlsx")
The data are already tidy as provided by the authors.
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
# Data provided by the authors actually contains two tables, separate them.
df.study6 <- d %>%
select("Subject", "Cond","Slack", "Large","tmest", "expense", "error")
df.paper_results <- d %>%
select("...10","...11","...12","...14")
df.paper_results <- df.paper_results %>%
rename(
col1 = ...10,
col2 = ...11,
col3 = ...12,
col4 = ...14
) %>%
filter(!is.na(col4))
df.paper_results <- df.paper_results %>%
slice(-1) # remove the first row
rownames(df.paper_results) <- df.paper_results$col1
df.paper_results <- df.paper_results %>% select(-col1)
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)
# reproduce the above results here
df.results <- df.study6 %>%
group_by(Cond) %>%
summarise(
mean = mean(expense, na.rm = TRUE),
lower = t.test(expense, conf.level = 0.95)$conf.int[1],
upper = t.test(expense, conf.level = 0.95)$conf.int[2]
) %>%
mutate(across(everything(), ~ round(.x, 2))) %>%
mutate(result_str=paste0("M = ", mean, ", 95% CI = [", lower, ", ", upper, "]"))
df.results
## # A tibble: 4 × 5
## Cond mean lower upper result_str
## <dbl> <dbl> <dbl> <dbl> <chr>
## 1 0 8.33 7.07 9.6 M = 8.33, 95% CI = [7.07, 9.6]
## 2 1 8.31 7.74 8.89 M = 8.31, 95% CI = [7.74, 8.89]
## 3 2 8.83 7.91 9.76 M = 8.83, 95% CI = [7.91, 9.76]
## 4 3 6.5 5.34 7.66 M = 6.5, 95% CI = [5.34, 7.66]
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
# set the values of the conditions by inspection from the previous results
df.study6 <- df.study6 %>%
mutate(
scarcity = case_when(
Cond == 0 ~ "time-poor",
Cond == 1 ~ "time-rich",
Cond == 2 ~ "time-poor",
Cond == 3 ~ "time-rich"),
account = case_when(
Cond == 0 ~ "small",
Cond == 1 ~ "small",
Cond == 2 ~ "large",
Cond == 3 ~ "large")
)
# perform anova
model <- aov(expense ~ scarcity * account, data = df.study6)
anova(model)
## Analysis of Variance Table
##
## Response: expense
## Df Sum Sq Mean Sq F value Pr(>F)
## scarcity 1 26.65 26.6456 5.6902 0.01981 *
## account 1 6.08 6.0779 1.2980 0.25853
## scarcity:account 1 24.17 24.1724 5.1621 0.02621 *
## Residuals 69 323.10 4.6827
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
# compute eta
df.eta <- data.frame(eta_squared(model, partial = TRUE)) %>%
mutate(across(-Parameter, ~ round(.x, 2)))
df.eta
## Parameter Eta2_partial CI CI_low CI_high
## 1 scarcity 0.08 0.95 0.01 1
## 2 account 0.02 0.95 0.00 1
## 3 scarcity:account 0.07 0.95 0.00 1
# prepare results for printing
tidy_anova <- broom::tidy(model) %>%
mutate(across(-term, ~ round(.x, 2)))
df2 = tidy_anova$df[4]
# Function to format APA-style string
format_anova <- function(row) {
p_text <- ifelse(row$p.value < .05, "< .05", paste0("= ", round(row$p.value, 3)))
glue("F({row$df}, {df2}) = {round(row$statistic, 2)}, p {p_text}, ηp² = {df.eta$Eta2_partial[3]}")
}
apa_results <- format_anova(tidy_anova[3,])
Were you able to reproduce the results you attempted to reproduce? If not, what part(s) were you unable to reproduce?
For the descriptive statistics, I was able to reproduce the means, but the confidence intervals were different:
For the Inferential statistics, I was able to reproduce the results from the paper
How difficult was it to reproduce your results?
It was farily easy to reproduce the results, with the exception of trying to figure out if I had done something wrong in computing the confidence intervals. I used chatGPT to help format the results in APA style.
What aspects made it difficult? What aspects made it easy?
The only tricky part was figuring out what the Cond numbers mapped to by matching my means to the means reported in the paper. The variables were reasonably named, which was helpful.