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')
source_data_hv <- haven::read_sav('data/Empathy Gap Study 1 data.sav')
#see how the data is organized
head(d)
## # A tibble: 6 x 125
## ID attachment1 attachment2 attachment3 attachment4 attachment5 attachment6
## <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 53 3 4 5 3 2 3
## 2 93 5 1 3 4 2 2
## 3 83 3 6 3 6 5 4
## 4 27 2 6 5 2 5 5
## 5 6 3 6 3 5 5 5
## 6 116 4 7 5 6 6 6
## # … with 118 more variables: attachment7 <dbl>, attachment8 <dbl>,
## # attachment9 <dbl>, attachment10 <dbl>, attachment11 <dbl>,
## # attachment12 <dbl>, attachment13 <dbl>, attachment14 <dbl>,
## # attachment15 <dbl>, attachment16 <dbl>, attachment17 <dbl>,
## # attachment18 <dbl>, attachment19 <dbl>, attachment20 <dbl>,
## # attachment21 <dbl>, attachment22 <dbl>, attachment23 <dbl>,
## # attachment24 <dbl>, attachment25 <dbl>, attachment26 <dbl>,
## # attachment27 <dbl>, attachment28 <dbl>, attachment29 <dbl>,
## # attachment30 <dbl>, attachment31 <dbl>, attachment32 <dbl>,
## # attachment33 <dbl>, attachment34 <dbl>, attachment35 <dbl>,
## # attachment36 <dbl>, FOBA1 <dbl>, FOBA2 <dbl>, FOBA3 <dbl>, FOBA4 <dbl>,
## # FOBA5 <dbl>, FOBA6 <dbl>, empathy1 <dbl>, empathy2 <dbl>, empathy3 <dbl>,
## # empathy4 <dbl>, empathy5 <dbl>, empathy6 <dbl>, empathy7 <dbl>,
## # empathy8 <dbl>, empathy9 <dbl>, empathy10 <dbl>, empathy11 <dbl>,
## # empathy12 <dbl>, empathy13 <dbl>, empathy14 <dbl>, empathy15 <dbl>,
## # empathy16 <dbl>, empathy17 <dbl>, empathy18 <dbl>, empathy19 <dbl>,
## # empathy20 <dbl>, empathy21 <dbl>, empathy22 <dbl>, empathy23 <dbl>,
## # empathy24 <dbl>, empathy25 <dbl>, empathy26 <dbl>, empathy27 <dbl>,
## # empathy28 <dbl>, age <dbl>, livedincanada <dbl>, orientation <dbl>,
## # inrel <dbl>, longterm <dbl>, dating <dbl>, shortterm <dbl>, intimate <dbl>,
## # otheropen <dbl>, drink <dbl>, children <dbl>, responseq1 <dbl>,
## # responseq2 <dbl>, responseq3 <dbl>, responseq4 <dbl>, reasontrue1 <dbl>,
## # motives1 <dbl>, reasontrue2 <dbl>, motives2 <dbl>, reasontrue3 <dbl>,
## # motives3 <dbl>, reasontrue4 <dbl>, motives4 <dbl>, reasontrue5 <dbl>,
## # motives5 <dbl>, reasontrue6 <dbl>, motives6 <dbl>, reasontrue7 <dbl>,
## # motives7 <dbl>, reasontrue8 <dbl>, motives8 <dbl>, suspicious <dbl>,
## # selfattractive <dbl>, otherattractive <dbl>, EmpathyPTtot <dbl>,
## # EmpathyFStot <dbl>, …
#figure out what do labels stand for
source_data_hv$condition %>% attr('labels')
## hypothetical real
## 0 1
source_data_hv$exchangeinfo %>% attr('labels')
## yes no
## 1 2
#n=132, condition-> 1:real 0:hypothetical, exchangeinfo-> 1:yes, 2:no
#get rid of unnecessary columns
d <- d[, c("ID", "condition", "exchangeinfo")]
d
## # A tibble: 132 x 3
## ID condition exchangeinfo
## <dbl> <dbl+lbl> <dbl+lbl>
## 1 53 1 [real] 1 [yes]
## 2 93 1 [real] 2 [no]
## 3 83 1 [real] 2 [no]
## 4 27 0 [hypothetical] 2 [no]
## 5 6 0 [hypothetical] 1 [yes]
## 6 116 0 [hypothetical] 1 [yes]
## 7 24 0 [hypothetical] 2 [no]
## 8 127 0 [hypothetical] 2 [no]
## 9 32 1 [real] 1 [yes]
## 10 73 1 [real] 2 [no]
## # … with 122 more rows
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
## Count participants with condition = 0 and exchangeinfo = 1
count_hypothetical <- sum(d$condition == 0 & d$exchangeinfo == 1)
# Subset the dataframe to include only participants with condition = 1
condition_0_subset <- d[d$condition == 0, ]
# Calculate the percentage
total_condition_0_participants <- nrow(condition_0_subset) # Total number of participants with condition = 1
percentage <- round((count_hypothetical / total_condition_0_participants) * 100)
# Print the count
cat("Number of participants in the hypothetical condition chose to exchange contact information with the unattractive potential date=", count_hypothetical, "\n")
## Number of participants in the hypothetical condition chose to exchange contact information with the unattractive potential date= 10
cat("Percentage of participants in the hypothetical condition chose to exchange contact information with the unattractive potential date=", percentage, "%\n")
## Percentage of participants in the hypothetical condition chose to exchange contact information with the unattractive potential date= 16 %
## Count participants with condition = 1 and exchangeinfo = 1
count_real <- sum(d$condition == 1 & d$exchangeinfo == 1)
# Subset the dataframe to include only participants with condition = 1
condition_1_subset <- d[d$condition == 1, ]
# Calculate the percentage
total_condition_1_participants <- nrow(condition_1_subset) # Total number of participants with condition = 1
percentage <- round((count_real / total_condition_1_participants) * 100)
# Print the count
cat("Number of participants in the real condition chose to exchange contact information with the unattractive potential date=", count_real, "\n")
## Number of participants in the real condition chose to exchange contact information with the unattractive potential date= 26
cat("Percentage of participants in the real condition chose to exchange contact information with the unattractive potential date=", percentage, "%\n")
## Percentage of participants in the real condition chose to exchange contact information with the unattractive potential date= 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
help (chisq.test)
# Create a contingency table
contingency_table <- table(d$condition, d$exchangeinfo)
# Print the contingency table
contingency_table
##
## 1 2
## 0 10 51
## 1 26 45
chisq.test(contingency_table, correct = FALSE )
##
## 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?
Both descriptive and inferencial analyses are reproduced.
How difficult was it to reproduce your results?
It was easy, especially because the data didn’t need a lot of tifying up for the puposes of these analysis.
What aspects made it difficult? What aspects made it easy?
It was difficult to understand the data table mostly due to labeling. The column names were not very informative. Also, it took me a minute to realize that it was originally an SPSS data and was labelled there. For instance, for the condition column, it was not obvious at first glance that 1=real 0=hypothetical or for “exchangeinfo” what does 1 or 2 stand for.