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
library(labelled)
# #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')
df.study1 <- d %>%
select(ID,condition,exchangeinfo) %>%
to_factor()
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%).
# reproduce the above results here
df.study1.stat <- df.study1 %>%
group_by(condition) %>%
summarise(
unattractive_count = sum(exchangeinfo == "yes", na.rm = TRUE),
total_count = n(),
unattractive_percentage = round((unattractive_count / total_count) * 100, 0)) %>%
ungroup()
kable(df.study1.stat)
| condition | unattractive_count | total_count | unattractive_percentage |
|---|---|---|---|
| hypothetical | 10 | 61 | 16 |
| real | 26 | 71 | 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
chisq_result <- chisq.test(df.study1$condition, df.study1$exchangeinfo, correct = FALSE)
sample_size <- nrow(df.study1)
print(chisq_result)
##
## Pearson's Chi-squared test
##
## data: df.study1$condition and df.study1$exchangeinfo
## X-squared = 6.7674, df = 1, p-value = 0.009284
print(sample_size)
## [1] 132
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 descriptive and inferential statistics for study 1’s results.
How difficult was it to reproduce your results?
It wasn’t too difficult. The hardest part for me to figure out was how to pull the word labels from the SPSS file to R. When I first reproduced the results I was first confused on what the value labels for the condition and exchangeinfo meant (i.e. what the 1 and 0 corresponded to in terms of what condition the participant was in). But thankfully I saw you included an optional package that turns those values into factors and uses word labels in the dataframe.
What aspects made it difficult? What aspects made it easy?
Difficult: not having clear value labels (everything numeric and not having the word labels at first). I had to do some research into the library package to figure out the code for how to change this.
Easy: Researchers including clear column names and labels.