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
library(dplyr)

# #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")
View(data)

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
View(d)

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)

table(d$Cond)
## 
##  0  1  2  3 
## 21 16 18 18
table(d$Subject)
## 
##   3   5   6   8   9  10  11  13  17  18  19  20  22  24  26  28  29  32  33  34 
##   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1 
##  35  37  38  39  40  42  43  44  45  46  47  48  49  50  54  55  58  59  60  61 
##   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1 
##  62  63  64  65  66  68  71  72  73  74  77  78  79  80  82  84  86  87  88  89 
##   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1   1 
##  92  93  97  99 100 102 103 105 106 107 108 109 110 
##   1   1   1   1   1   1   1   1   1   1   1   1   1
# reproduce the above results here
#Poor participants,Large account = Condition 2
mean_value <- mean(d$expense[d$Cond == 2]) #computing the mean.
n <-length(d$expense[d$Cond == 2]) #Now let’s compute the standard error of the mean. 
standard_deviation <- sd(d$expense[d$Cond == 2])
standard_error <- standard_deviation / sqrt(n)
alpha = 0.05
degrees_of_freedom = n - 1
t_score = qt(p=alpha/2, df=degrees_of_freedom,lower.tail=F)
print(t_score) #Determine the t-score that is linked to the confidence level.
## [1] 2.109816
margin_error <- t_score * standard_error #Compute the margin of error and form the confidence interval.
# Calculate the lower bound 
lower_bound <- mean_value - margin_error
# Calculate the upper bound
upper_bound <- mean_value + margin_error
#Print mean value.
mean_value
## [1] 8.833333
# Print the confidence interval
print(c(lower_bound,upper_bound))
## [1] 7.910843 9.755823
#Poor participant, small account = Condition 0
mean(d$expense[d$Cond == 0])
## [1] 8.333333
mean_value <- mean(d$expense[d$Cond == 0]) #computing the mean.
n <-length(d$expense[d$Cond == 0]) #Now let’s compute the standard error of the mean. 
standard_deviation <- sd(d$expense[d$Cond == 0])
standard_error <- standard_deviation / sqrt(n)
alpha = 0.05
degrees_of_freedom = n - 1
t_score = qt(p=alpha/2, df=degrees_of_freedom,lower.tail=F)
print(t_score) #Determine the t-score that is linked to the confidence level.
## [1] 2.085963
margin_error <- t_score * standard_error #Compute the margin of error and form the confidence interval.
# Calculate the lower bound 
lower_bound <- mean_value - margin_error
# Calculate the upper bound
upper_bound <- mean_value + margin_error
#Print mean value.
mean_value
## [1] 8.333333
# Print the confidence interval
print(c(lower_bound,upper_bound))
## [1] 7.067489 9.599178
#Rich participant, Large account = Condition 3
mean(d$expense[d$Cond == 3])
## [1] 6.5
#Poor participant, small account = Condition 0
mean_value <- mean(d$expense[d$Cond == 3]) #computing the mean.
n <-length(d$expense[d$Cond == 3]) #Now let’s compute the standard error of the mean. 
standard_deviation <- sd(d$expense[d$Cond == 3])
standard_error <- standard_deviation / sqrt(n)
alpha = 0.05
degrees_of_freedom = n - 1
t_score = qt(p=alpha/2, df=degrees_of_freedom,lower.tail=F)
print(t_score) #Determine the t-score that is linked to the confidence level.
## [1] 2.109816
margin_error <- t_score * standard_error #Compute the margin of error and form the confidence interval.
# Calculate the lower bound 
lower_bound <- mean_value - margin_error
# Calculate the upper bound
upper_bound <- mean_value + margin_error
#Print mean value.
mean_value
## [1] 6.5
# Print the confidence interval
print(c(lower_bound,upper_bound))
## [1] 5.340009 7.659991
#Poor participant, Small account = Condition 1
mean(d$expense[d$Cond == 1])
## [1] 8.3125
#Poor participant, small account = Condition 0
mean_value <- mean(d$expense[d$Cond == 1]) #computing the mean.
n <-length(d$expense[d$Cond == 1]) #Now let’s compute the standard error of the mean. 
standard_deviation <- sd(d$expense[d$Cond == 1])
standard_error <- standard_deviation / sqrt(n)
alpha = 0.05
degrees_of_freedom = n - 1
t_score = qt(p=alpha/2, df=degrees_of_freedom,lower.tail=F)
print(t_score) #Determine the t-score that is linked to the confidence level.
## [1] 2.13145
margin_error <- t_score * standard_error #Compute the margin of error and form the confidence interval.
# Calculate the lower bound 
lower_bound <- mean_value - margin_error
# Calculate the upper bound
upper_bound <- mean_value + margin_error
#Print mean value.
mean_value
## [1] 8.3125
# Print the confidence interval
print(c(lower_bound,upper_bound))
## [1] 7.737972 8.887028

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


```r
# reproduce the above results here
#IV1 = scarcity condition; Slack? (0 = Poor, 1 = Rich)
#IV2 = account condition; Large? (0 = Small Account, 1 = Large Account)
res.aov2 <- aov(expense ~ Slack * Large, data = d)
summary(res.aov2)
##             Df Sum Sq Mean Sq F value Pr(>F)  
## Slack        1   26.6  26.646   5.690 0.0198 *
## Large        1    6.1   6.078   1.298 0.2585  
## Slack:Large  1   24.2  24.172   5.162 0.0262 *
## 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?

Yes, I was able to reproduce the general results although all the values are not exactly the same.

How difficult was it to reproduce your results?

Yes it was hard because the author did not label anything or provide a codebook so I had to make a lot of inferences of what variables meant.

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

It was difficult because I did not have codebook. But I am happy because I was able to figure out how to run all of this with the power of google.