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
library(dplyr)

# #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

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

#see what data looks like
head(d) #long format
## # A tibble: 6 x 5
##   group  participant subscale item                    `Agreement (0=complete di…
##   <chr>        <dbl> <chr>    <chr>                                        <dbl>
## 1 Moroc…           1 PAST     1. Para mí son muy imp…                          4
## 2 Moroc…           1 PAST     2. Los jóvenes deben c…                          4
## 3 Moroc…           1 PAST     3. Creo que las person…                          5
## 4 Moroc…           1 PAST     4. La juventud de hoy …                          2
## 5 Moroc…           1 PAST     5. Los ancianos saben …                          4
## 6 Moroc…           1 PAST     6. El modo correcto de…                          3
colnames(d)[colnames(d) == "Agreement (0=complete disagreement; 5=complete agreement)"] <- "Agreement"
#wide format might be more informative for this data, as we will work with the mean sores of the questionnare items and it woudn't make sense to have it repeating 21 rows.

#I tried converting the dataset to wide format but I failed terribly and lost more than an hour working on it:D. So I will try to move on with the long format.Mainly because item names are different in two languages. It would be great if you can provide me with the solution later on. Or was it a bad idea try to work with wide format anyway?

#compute mean agreement scores
# d <- d %>%
#   group_by(participant) %>%
#   mutate(avg_agreement = round(mean(Agreement[1:21], na.rm = TRUE), 1))

#change young Spinard to Spinard
d$group <- ifelse(d$group == "young Spaniard", "Spaniard", d$group)

Step 4: Run analysis

Pre-processing

Descriptive statistics

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

library(dplyr)

d_groups <- d %>%
  group_by(group, subscale) %>%
  summarize(avg_agreement = round(mean(Agreement, na.rm = TRUE), 1), .groups = "drop")


figure<- ggplot(d_groups, aes(x = factor(group, levels = rev(unique(group))), y = avg_agreement, fill = subscale)) +
  geom_bar(stat = "identity", position = "dodge") +
  labs(x = "Group", y = "Rating") +
  scale_fill_manual(values = c("PAST" = "blue", "FUTURE" = "red")) +
  theme_minimal() +
  ylim(0, 4) +
  scale_y_continuous(limits = c(0, 4), breaks = seq(0, 4, by = 0.25))
figure

#the values seem to replicate

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

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

# reproduce the above results here

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

Step 5: Reflection

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

Decriptives are replictaed.

How difficult was it to reproduce your results?

After finishing the descriptives section I have already spend 3 hours on it because of the reasons mentined below.I recognize that it is my mistake and I should have progressed way more in 3 hours if didn’t get lost on small details or… be better at using R

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

I tried converting the dataset to wide format but I falied terribly and lost more than an hour working on it. So I will try to move on with the long format.Mainly because item names are different in two languages. It would be grat if you can provide me with the solution later on. Or was it a bad idea try to work with wide format anyway? Fig.2 y axis starts from 2 and not 0 which I don’t like, but I tried to do the same to be replicate the figure.I recived an error when I tried to draw the y axis from 2-4. I also received an error when I tried to reverse the order of subsacles and make it the same as the original figure so unfortunately it does not look exactly the same.