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


# #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
setwd("~/Library/CloudStorage/OneDrive-Personal/pset3b")

d <- read_excel("DeLaFuenteEtAl_2014_RawData.xls", sheet=3)

Step 3: Tidy data

tidy_d <- d %>%
  rename(Agreement = `Agreement (0=complete disagreement; 5=complete agreement)`)
print(head(tidy_d))
## # A tibble: 6 × 5
##   group    participant subscale item                                   Agreement
##   <chr>          <dbl> <chr>    <chr>                                      <dbl>
## 1 Moroccan           1 PAST     1. Para mí son muy importantes las tr…         4
## 2 Moroccan           1 PAST     2. Los jóvenes deben conservar las tr…         4
## 3 Moroccan           1 PAST     3. Creo que las personas eran más fel…         5
## 4 Moroccan           1 PAST     4. La juventud de hoy en día necesita…         2
## 5 Moroccan           1 PAST     5. Los ancianos saben más que los jóv…         4
## 6 Moroccan           1 PAST     6. El modo correcto de hacer las cosa…         3

Step 4: Run analysis

Pre-processing

tidy_d <- tidy_d %>%
  mutate(group = ifelse(group == "young Spaniard", "Spaniard", group))

Descriptive statistics

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

# Calculate mean, sd, and se for each group and subscale

summary_d <- tidy_d %>%
  group_by(group, subscale) %>%
  summarise(
    mean = mean(Agreement),
    sd = sd(Agreement),
    se = sd / sqrt(n())
  ) %>%
  ungroup()

# Create the plot
p <- ggplot(summary_d, aes(x = subscale, y = mean, fill = group)) +
  geom_bar(stat = "identity", position = "dodge") +
  labs(title = "Mean Agreement by Subscale",
       x = "Subscale",
       y = "Mean Agreement") +
  scale_fill_manual(values = c("blue", "red")) +  # Set colors for 'blue' and 'red'
  theme_minimal()

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

tidy_d$unique_id <- interaction(tidy_d$group, tidy_d$participant)

# Run a mixed ANOVA
anova_results <- aov_ez("unique_id", "Agreement", tidy_d, between = "group", within = "subscale")

# Get the summary of the ANOVA
summary_table <- summary(anova_results)

# Extract the F value, degrees of freedom, and p-value for the interaction effect
#I dont know how to do this?

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

# reproduce the above results here
mean_agreement <- tidy_d %>%
  group_by(group, subscale, unique_id) %>%
  summarize(mean_agreement = mean(Agreement, na.rm = TRUE), .groups = 'drop')

t_test_results <- t.test(mean_agreement ~ group, data = subset(mean_agreement, subscale == "PAST"))

# Output the results
print(t_test_results)
## 
##  Welch Two Sample t-test
## 
## data:  mean_agreement by group
## t = 3.8562, df = 74.91, p-value = 0.0002416
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.2850812 0.8944060
## sample estimates:
## mean in group Moroccan mean in group 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
#Im not sure how?

Step 5: Reflection

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 some of the results. I didnt know how to extract the F value, degrees of freedom, or pvalue intereaction effect.

ANSWER HERE Very difficult, i had to reach out to friends and use chatgpt and it still took me forever to get part of the way through.

ANSWER HERE

I just dont have a lot of experience in R so it would have been helpful to have more instructions and guidance. I dont feel like i learned much :(

ANSWER HERE