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(ggplot2)
library(jtools)
# #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)
colnames(d)[5] <- "agreement"
Participant 24, 25 and 40 are messed up!
Assumption:
row 501 - 504: participant is 24 instead of 40
row 505 - 521: participant is 25 instead of 40
row 1341 - 1344: participant is 24 instead of 40
row 1345 - 1361: participant is 25 instead of 40
d$participant[501:504] <- 24
d$participant[505:521] <- 25
d$participant[1341:1344] <- 24
d$participant[1345:1361] <- 25
# make participant ID unique
d_tidy <- d %>%
mutate(participant = ifelse(group == "young Spaniard",
participant + 40, participant)) %>%
group_by(group, participant, subscale) %>%
summarize(score = mean(agreement)) %>%
ungroup()
d_figure <- d_tidy %>%
group_by(group, subscale) %>%
summarize(score_mean = mean(score),
score_se = sd(score)/sqrt(n()))
d_figure$group <- factor(d_figure$group,
levels = c("young Spaniard", "Moroccan"))
d_figure$subscale <- factor(d_figure$subscale,
levels = c("PAST", "FUTURE"))
Try to recreate Figure 2 (fig2.png, also included in the same folder as this Rmd file):
ggplot(d_figure, aes(x = group, y = score_mean, fill = subscale)) +
geom_bar(stat="identity", color="black", position=position_dodge(), width = 0.7)+
theme_apa() +
coord_cartesian(ylim = c(2,4)) +
geom_errorbar(aes(ymin = score_mean - score_se, ymax = score_mean + score_se),
width=0,
position=position_dodge(.7)) +
scale_fill_manual(labels = c("Past-Focused Statements", "Future-Focused Statements"),
values=c('#5e5e5e','#b3b3b3')) +
scale_x_discrete(labels= c("Spaniards", "Moroccans")) +
labs(y = "Rating", x = "")
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
aov_mod <- aov(score ~ group*subscale + Error(as.factor(participant)/subscale),
data= d_tidy)
summary(aov_mod)
##
## Error: as.factor(participant)
## Df Sum Sq Mean Sq F value Pr(>F)
## group 1 0.604 0.6036 2.881 0.0936 .
## Residuals 78 16.341 0.2095
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Error: as.factor(participant):subscale
## Df Sum Sq Mean Sq F value Pr(>F)
## subscale 1 4.15 4.151 8.098 0.00566 **
## group:subscale 1 9.81 9.815 19.145 3.71e-05 ***
## Residuals 78 39.99 0.513
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
F(1, 78) = 19.15, p < 0.001, η^2 = 0.25.
Moroccans showed greater agreement with past-focused statements than Spaniards did, t(78) = 4.04, p = .001,
# reproduce the above results here
d_past <- d_tidy %>%
filter(subscale == "PAST")
t.test(score ~ group, data = d_past, var.equal = TRUE)
##
## Two Sample t-test
##
## data: score by group
## t = 4.0034, df = 78, p-value = 0.0001413
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## 0.3107666 0.9255970
## sample estimates:
## mean in group Moroccan mean in group young Spaniard
## 3.293182 2.675000
t(78) = 4.00, p < 0.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)
# reproduce the above results here
d_future <- d_tidy %>%
filter(subscale == "FUTURE")
t.test(score ~ group, data = d_future, var.equal = TRUE)
##
## Two Sample t-test
##
## data: score by group
## t = -3.3637, df = 78, p-value = 0.001195
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
## -0.5929718 -0.1520282
## sample estimates:
## mean in group Moroccan mean in group young Spaniard
## 3.1200 3.4925
t(78) = -3.36, p = 0.001.
Were you able to reproduce the results you attempted to reproduce? If not, what part(s) were you unable to reproduce?
My error bars in the figure looked different from the original one. ANOVA and t-test results are different too.
How difficult was it to reproduce your results?
Fairly difficult. Took me some time to replicate the figure. Limiting the y range to 2-4 is an interesting move. Took me much more time to realize and fix the errors in the data.
What aspects made it difficult? What aspects made it easy?
IDs for a few participants are messed up. Participant ID is not unique and is numeric. It would be better if the author provided descriptive statistics like mean and standard deviation along the way.