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')
tidy_df <- d %>%
select(condition, exchangeinfo, otherfocused_motives, selffocused_motives)
# View the first few rows of the selected dataframe
print(head(tidy_df))
## # A tibble: 6 × 4
## condition exchangeinfo otherfocused_motives selffocused_motives
## <dbl+lbl> <dbl+lbl> <dbl> <dbl>
## 1 1 [real] 1 [yes] 3.5 3.38
## 2 1 [real] 2 [no] 2.5 2.4
## 3 1 [real] 2 [no] 4.5 2.75
## 4 0 [hypothetical] 2 [no] 1 1.75
## 5 0 [hypothetical] 1 [yes] 4 3.5
## 6 0 [hypothetical] 1 [yes] 4 2.75
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%).
# Calculate the count and percentage for each condition
results <- tidy_df %>%
mutate(exchangeinfo = exchangeinfo == 1) %>%
group_by(condition) %>%
summarise(
count_exchange = sum(exchangeinfo, na.rm = TRUE),
total = n(),
percentage = (count_exchange / total) * 100
) %>%
mutate(condition = if_else(condition == 1, "real", "hypothetical"))
# Display the results
print(results)
## # A tibble: 2 × 4
## condition count_exchange total percentage
## <chr> <int> <int> <dbl>
## 1 hypothetical 10 61 16.4
## 2 real 26 71 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.
# First create the contingency table
contingency_table <- tidy_df %>%
mutate(exchangeinfo = exchangeinfo == 1) %>%
count(condition, exchangeinfo) %>%
pivot_wider(names_from = exchangeinfo, values_from = n, values_fill = list(n = 0)) %>%
select(-condition) %>% # Remove the condition column to get a proper table
as.matrix() # Convert to matrix as chisq.test expects a matrix or table
# Make sure the matrix has dimnames for the chi-square test
dimnames(contingency_table) <- list(condition = c("hypothetical", "real"),
exchangeinfo = c("no", "yes"))
# Now perform the chi-square test
chi_square_result <- chisq.test(contingency_table, correct = FALSE)
# Output the results
chi_square_result
##
## Pearson's Chi-squared test
##
## data: contingency_table
## 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 descriptive statistics and also the inferential statistics without any problem.
How difficult was it to reproduce your results?
It was pretty easy.
What aspects made it difficult? What aspects made it easy?
I used chatGPT to help me with the R code, since I was familiar with the process in python. I found that it was able to reproduce the results exactly, so since my task was then to simply verify that we could reproduce the problem overall I think this was an effective and easy approach.