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')
d_tidy <- d |>
pivot_longer(
cols = matches("\\d"), # any column containing a digit
names_to = c("measure_type", "item"),
names_pattern = "^([a-zA-Z]+)(\\d+)$",
values_to = "score"
)
d_tidy
## # A tibble: 11,880 × 38
## ID age livedincanada orientation inrel longterm dating shortterm
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 53 18 3 1 2 2 1 1
## 2 53 18 3 1 2 2 1 1
## 3 53 18 3 1 2 2 1 1
## 4 53 18 3 1 2 2 1 1
## 5 53 18 3 1 2 2 1 1
## 6 53 18 3 1 2 2 1 1
## 7 53 18 3 1 2 2 1 1
## 8 53 18 3 1 2 2 1 1
## 9 53 18 3 1 2 2 1 1
## 10 53 18 3 1 2 2 1 1
## # ℹ 11,870 more rows
## # ℹ 30 more variables: intimate <dbl>, otheropen <dbl>, drink <dbl>,
## # children <dbl>, suspicious <dbl>, selfattractive <dbl>,
## # otherattractive <dbl>, EmpathyPTtot <dbl>, EmpathyFStot <dbl>,
## # EmpathyECtot <dbl>, EmpathyPDtot <dbl>, fobstot <dbl>,
## # attachmentavoidance <dbl>, attachmentanxiety <dbl>, stateguilttot <dbl>,
## # stateempathytot <dbl>, excitementtot <dbl>, compatibilitytot <dbl>, …
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
d |>
group_by(condition) |>
summarize(
n = n(),
n_exchanged = sum(exchangeinfo == 1),
percent = round(100 * n_exchanged / n, 1)
)
## # A tibble: 2 × 4
## condition n n_exchanged percent
## <dbl+lbl> <int> <int> <dbl>
## 1 0 [hypothetical] 61 10 16.4
## 2 1 [real] 71 26 36.6
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.test(d$condition, d$exchangeinfo, correct = FALSE )
##
## Pearson's Chi-squared test
##
## data: d$condition and d$exchangeinfo
## X-squared = 6.7674, df = 1, p-value = 0.009284
Were you able to reproduce the results you attempted to reproduce? If not, what part(s) were you unable to reproduce?
I was able to reproduce the results as expected.
How difficult was it to reproduce your results?
It was relatively straightforward!
What aspects made it difficult? What aspects made it easy?
I am confused about why we needed to tidy the data when it was significantly easier to just use the original dataset for both analyses. I struggled with using the tidy dataset then realized I could just use the original in less lines of code and get the same results.