For this exercise, please try to reproduce the results from Study 1 of the associated paper (Joel, Teper, & MacDonald, 2014). The PDF of the paper is included in the same folder as this Rmd file.
In study 1, 150 introductory psychology students were randomly assigned to a “real” or a “hypothetical” condition. In the real condition, participants believed that they would have a real opportuniy to connect with potential romantic partners. In the hypothetical condition, participants simply imagined that they are on a date. All participants were required to select their favorite profile and answer whether they were willing to exchange contact information.
Below is the specific result you will attempt to reproduce (quoted directly from the results section of Study 1):
We next tested our primary hypothesis that participants would be more reluctant to reject the unattractive date when they believed the situation to be real rather than hypothetical. Only 10 of the 61 participants in the hypothetical condition chose to exchange contact information with the unattractive potential date (16%). In contrast, 26 of the 71 participants in the real condition chose to exchange contact information (37%). A chi-square test of independence indicated that participants were significantly less likely to reject the unattractive potential date in the real condition compared with the hypothetical condition, X^2(1, N = 132) = 6.77, p = .009.
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(broom)
library(labelled)# converts SPSS's labelled to R's factor
# Just Study 1
d <- read_sav('data/Empathy Gap Study 1 data.sav')
var.interest = c("ID","condition","exchangeinfo","otherfocused_motives","selffocused_motives", "otherattractive" , "selfattractive")
s.d = d %>% select(var.interest) #get our selected dataset
Only 10 of the 61 participants in the hypothetical condition chose to exchange contact information with the unattractive potential date (16%). In contrast, 26 of the 71 participants in the real condition chose to exchange contact information (37%).
# find the hypothetical condition participants and the ratio of those who shared their contact info.
n.hypoth <- s.d %>% filter(condition == 0) %>% nrow()
n.hypoth.ex <- s.d %>% filter(condition == 0, exchangeinfo == 1) %>% nrow()
n.real <- s.d %>% filter(condition == 1) %>% nrow()
n.real.ex <- s.d %>% filter(condition == 1, exchangeinfo == 1) %>% nrow()
print(paste0("Only ",n.hypoth.ex," of the ",n.hypoth," participants in the hypothetical condition chose to exchange contact information with the unattractive potential date (",round(n.hypoth.ex/n.hypoth * 100),"%). In contrast, ",n.real," of the ",n.real.ex," participants in the real condition chose to exchange contact information (",round(n.real.ex/n.real * 100),"%%)."))
## [1] "Only 10 of the 61 participants in the hypothetical condition chose to exchange contact information with the unattractive potential date (16%). In contrast, 71 of the 26 participants in the real condition chose to exchange contact information (37%%)."
A chi-square test of independence indicated that participants were significantly less likely to reject the unattractive potential date in the real condition compared with the hypothetical condition, X^2(1, N = 132) = 6.77, p = .009.
Hint: if you are using the function chisq.test(), make sure to set the continuity correction to false (“correct = FALSE”) since sample size is greater than 20.
# reproduce the above results here
chi.sq <- chisq.test(x = s.d$condition, y = s.d$exchangeinfo, correct = F)
print(paste0("A chi-square test of independence indicated that participants were significantly less likely to reject the unattractive potential date in the real condition compared with the hypothetical condition, X^2(",chi.sq$parameter,", N = ",nrow(s.d),") = ",round(chi.sq$statistic,2),", p = ",round(chi.sq$p.value,3),"."))
## [1] "A chi-square test of independence indicated that participants were significantly less likely to reject the unattractive potential date in the real condition compared with the hypothetical condition, X^2(1, N = 132) = 6.77, p = 0.009."
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 all the results in the prompts above
How difficult was it to reproduce your results?
It was very easy
What aspects made it difficult? What aspects made it easy?
Data was cleanly labeled, in long format, statistical methods were clear.