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.

Methods summary:

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.


Target outcomes:

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).


Step 1: Load packages

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
# install.packages("car")
# library(car)

# #optional packages/functions:
#install.packages("afex")
library(afex) # anova functions
# library(ez) # anova functions 2
# library(scales) # for plotting
# std.err <- function(x) sd(x)/sqrt(length(x)) # standard error
# 
# # Reading in additional package
# install.packages("rstatix")
# library(rstatix)

Step 2: Load data

# Just Experiment 2
data_path <- 'data/DeLaFuenteEtAl_2014_RawData.xls'
d <- read_excel(data_path, sheet=3)

Step 3: Tidy data

d = d %>% 
  rename(agreement = `Agreement (0=complete disagreement; 5=complete agreement)`)

Step 4: Run analysis

Pre-processing

# Checking variable types
typeof(d$group)
## [1] "character"
typeof(d$participant)
## [1] "double"
d$participant = as_factor(d$participant)
typeof(d$subscale)
## [1] "character"
d$subscale = as_factor(d$subscale)
typeof(d$item)
## [1] "character"
typeof(d$agreement)
## [1] "double"
# Variables are funky. Participant ID values are not unique by condition - there are duplicates

d$PID <- paste(d$group, d$participant, sep= "_")
d$PID = as_factor(d$PID)
d = d %>% 
  select(PID, group, subscale, item, agreement)

Descriptive statistics

Try to recreate Figure 2 (fig2.png, also included in the same folder as this Rmd file):

time = d %>% 
  group_by(PID, group, subscale) %>% 
  summarise(agreement_means = mean(agreement, na.rm = TRUE))


time = time %>% 
  group_by(group, subscale) %>% 
  summarise(means = mean(agreement_means, na.rm = TRUE))


p <- ggplot(data=time, aes(x=group, y=means, fill=subscale)) +
geom_bar(stat="identity", color="black", position=position_dodge())+
  theme_minimal() + ylim(0, 4)

p

Inferential statistics

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 <- aov_ez("PID", "agreement", d, between = "group", within = "subscale", detailed = TRUE)

print(anova)
## Anova Table (Type 3 tests)
## 
## Response: agreement
##           Effect    df  MSE         F  ges p.value
## 1          group 1, 76 0.20      2.19 .008    .143
## 2       subscale 1, 76 0.50   7.98 ** .070    .006
## 3 group:subscale 1, 76 0.50 18.35 *** .147   <.001
## ---
## Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1

Moroccans showed greater agreement with past-focused statements than Spaniards did, t(78) = 4.04, p = .001,

# reproduce the above results here

past = d %>% 
  filter(subscale == "PAST") %>% 
  group_by(group, PID) %>% 
  summarise(agreement_means = mean(agreement, na.rm = TRUE))

t <- t.test(agreement_means ~ group, data = past)
t
## 
##  Welch Two Sample t-test
## 
## data:  agreement_means by group
## t = 3.8562, df = 74.91, p-value = 0.0002416
## alternative hypothesis: true difference in means between group Moroccan and group young Spaniard is not equal to 0
## 95 percent confidence interval:
##  0.2850812 0.8944060
## sample estimates:
##       mean in group Moroccan mean in group young Spaniard 
##                     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
future = d %>% 
  filter(subscale == "FUTURE") %>% 
  group_by(group, PID) %>% 
  summarise(agreement_means = mean(agreement, na.rm = TRUE))

t <- t.test(agreement_means ~ group, data = future)
t
## 
##  Welch Two Sample t-test
## 
## data:  agreement_means by group
## t = -3.2098, df = 70.047, p-value = 0.002005
## alternative hypothesis: true difference in means between group Moroccan and group young Spaniard is not equal to 0
## 95 percent confidence interval:
##  -0.5762537 -0.1345797
## sample estimates:
##       mean in group Moroccan mean in group young Spaniard 
##                     3.138333                     3.493750

Step 5: Reflection

Were you able to reproduce the results you attempted to reproduce? If not, what part(s) were you unable to reproduce?

Yes

How difficult was it to reproduce your results?

This was much more difficult than the earlier problem.

What aspects made it difficult? What aspects made it easy?

The data was poorly organised, but thankfully variable names and values were easy enough to interpret. Figuring out all the issues and wrangling the data took a couple hours.