For this exercise, please try to reproduce the results from Experiment 2 of the associated paper (de la Fuente, Santiago, Roman, Dumitrache, & Casasanto, 2014). The PDF of the paper is included in the same folder as this Rmd file.
Researchers tested the question of whether temporal focus differs between Moroccan and Spanish cultures, hypothesizing that Moroccans are more past-focused, whereas Spaniards are more future-focused. Two groups of participants (\(N = 40\) Moroccan and \(N=40\) Spanish) completed a temporal-focus questionnaire that contained questions about past-focused (“PAST”) and future-focused (“FUTURE”) topics. In response to each question, participants provided a rating on a 5-point Likert scale on which lower scores indicated less agreement and higher scores indicated greater agreement. The authors then performed a mixed-design ANOVA with agreement score as the dependent variable, group (Moroccan or Spanish, between-subjects) as the fixed-effects factor, and temporal focus (past or future, within-subjects) as the random effects factor. In addition, the authors performed unpaired two-sample t-tests to determine whether there was a significant difference between the two groups in agreement scores for PAST questions, and whether there was a significant difference in scores for FUTURE questions.
Below is the specific result you will attempt to reproduce (quoted directly from the results section of Experiment 2):
According to a mixed analysis of variance (ANOVA) with group (Spanish vs. Moroccan) as a between-subjects factor and temporal focus (past vs. future) as a within-subjectS factor, temporal focus differed significantly between Spaniards and Moroccans, as indicated by a significant interaction of temporal focus and group, F(1, 78) = 19.12, p = .001, ηp2 = .20 (Fig. 2). Moroccans showed greater agreement with past-focused statements than Spaniards did, t(78) = 4.04, p = .001, and Spaniards showed greater agreement with future-focused statements than Moroccans did, t(78) = −3.32, p = .001. (de la Fuente et al., 2014, p. 1685).
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(ez) # for running ANOVA
# #optional packages/functions:
# library(afex) # anova functions
# library(ez) # anova functions 2
# library(scales) # for plotting
# std.err <- function(x) sd(x)/sqrt(length(x)) # standard error
# Just Experiment 2
data_path <- 'data/DeLaFuenteEtAl_2014_RawData.xls'
d <- read_excel(data_path, sheet=3)
df <- d %>%
rename(
agreement = `Agreement (0=complete disagreement; 5=complete agreement)`
) %>%
mutate(
group = case_when(
group == "young Spaniard" ~ "Spanish",
TRUE ~ group
),
group = factor(group, levels = c("Spanish", "Moroccan")),
participant = paste0(group, "_", participant),
subscale = factor(subscale, levels = c("PAST", "FUTURE"))
)
# making a wide df for agreement rate
df_wide <- df %>%
group_by(participant, group, subscale) %>%
summarise(mean_agree = mean(agreement), .groups = "drop") %>%
pivot_wider(
names_from = subscale,
values_from = mean_agree
) %>%
mutate(
PAST = as.numeric(PAST),
FUTURE = as.numeric(FUTURE)
)
df_wide_clean <- df_wide %>%
filter(!is.na(PAST), !is.na(FUTURE))
df_long_clean <- df_wide_clean %>%
pivot_longer(cols = c(PAST, FUTURE),
names_to = "temporal_focus",
values_to = "agreement")
Try to recreate Figure 2 (fig2.png, also included in the same folder as this Rmd file):
# pivoting long for plot
df_long <- df_wide %>%
pivot_longer(cols = c(PAST, FUTURE),
names_to = "subscale",
values_to = "agreement")
ggplot(df_long, aes(x = group, y = agreement, fill = subscale)) +
stat_summary(fun = mean, geom = "bar", position = position_dodge(.8)) +
stat_summary(fun.data = mean_se, geom = "errorbar",
position = position_dodge(.8), width = .2) +
labs(
x = "Group",
y = "Agreement Rating",
title = "Mean Agreement With Past vs. Future Statements"
) +
theme_minimal()
According to a mixed analysis of variance (ANOVA) with group (Spanish vs. Moroccan) as a between-subjects factor and temporal focus (past vs. future) as a within-subjects factor, temporal focus differed significantly between Spaniards and Moroccans, as indicated by a significant interaction of temporal focus and group, F(1, 78) = 19.12, p = .001, ηp2 = .20 (Fig. 2).
# reproduce the above results here
anova_data <- df_long %>%
rename(temporal_focus = subscale)
anova_results <- ezANOVA(
data = df_long_clean,
dv = agreement,
wid = participant,
within = .(temporal_focus),
between = .(group),
detailed = TRUE
)
anova_results
## $ANOVA
## Effect DFn DFd SSn SSd F p
## 1 (Intercept) 1 76 1543.4554821 15.24977 7692.090448 3.991708e-78
## 2 group 1 76 0.4398308 15.24977 2.191977 1.428650e-01
## 3 temporal_focus 1 76 3.9662047 37.77666 7.979308 6.040164e-03
## 4 group:temporal_focus 1 76 9.1188907 37.77666 18.345608 5.327735e-05
## p<.05 ges
## 1 * 0.966785451
## 2 0.008226326
## 3 * 0.069591536
## 4 * 0.146734962
Moroccans showed greater agreement with past-focused statements than Spaniards did, t(78) = 4.04, p = .001,
# reproduce the above results here
df_wide_clean$group <- relevel(df_wide_clean$group, ref = "Moroccan")
t_past <- t.test(PAST ~ group, df_wide_clean, var.equal = TRUE)
t_past
##
## Two Sample t-test
##
## data: PAST by group
## t = 3.8562, df = 76, p-value = 0.0002394
## alternative hypothesis: true difference in means between group Moroccan and group Spanish is not equal to 0
## 95 percent confidence interval:
## 0.2851528 0.8943343
## sample estimates:
## mean in group Moroccan mean in group Spanish
## 3.280886 2.691142
and Spaniards showed greater agreement with future-focused statements than Moroccans did, t(78) = −3.32, p = .001.(de la Fuente et al., 2014, p. 1685)
# reproduce the above results here
t_future <- t.test(FUTURE ~ group, data = df_wide_clean, var.equal = TRUE)
t_future
##
## Two Sample t-test
##
## data: FUTURE by group
## t = -3.3898, df = 76, p-value = 0.001112
## alternative hypothesis: true difference in means between group Moroccan and group Spanish is not equal to 0
## 95 percent confidence interval:
## -0.5990628 -0.1556380
## sample estimates:
## mean in group Moroccan mean in group Spanish
## 3.116239 3.493590
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 all of the results, but had slightly different results. I had differences in degrees of freedom and small shifts in the test statistics based on the way that I dropped participants. My results matched the direction and magnitude of the paper.
How difficult was it to reproduce your results?
The analyses themselves weren’t difficult, but getting the data correctly organized required a decent amount of debugging steps.
What aspects made it difficult? What aspects made it easy?
I was unsure of how to properly treat some of the inconsistencies in the data. The results didn’t match exactly what was written in the paper and I believe it was because of the way that I managed the NAs.