March7_EM6_Analyses

Set up data and libraries

Hypothesis 1

Hypothesis: As the cost to use external resources increases, participants will be inclined to use them less and instead rely more on memory. On the other hand, as the cost to use internal resources increases (i.e. maintaining memory), participants will be inclined to use them less and instead rely more on external resources. Our sampling-delay conditions impose a cost only on external resource use. Our maintenance-delay conditions impose a comparable external use cost and an internal use cost. On balance then, participants should prefer to use less internal memory (and instead rely more on external resources) in the maintenance-delay versus sampling-delay conditions. We expect to see this reflected in significantly lower study times and lower memory usage in the maintenance-delay conditions.

Test: paired TOSTER t-test with a smallest-effect-size-of-interest (SESOI) of Cohen’s dz = 0.4, one for MU and one for Study Time

library(TOSTER)
t_TOST(mean_MU ~ condsFile, data = study_time_FR, paired = TRUE,
       eqb = 0.4, eqbound_type = "SMD")
Warning: setting bound type to SMD produces biased results!

Paired t-test

The equivalence test was non-significant, t(26) = 0.86, p = 0.2
The null hypothesis test was non-significant, t(26) = -1.21, p = 0.24
NHST: don't reject null significance hypothesis that the effect is equal to zero 
TOST: don't reject null equivalence hypothesis

TOST Results 
                 t df p.value
t-test     -1.2140 26   0.236
TOST Lower  0.8645 26   0.198
TOST Upper -3.2924 26   0.001

Effect Sizes 
              Estimate     SE              C.I. Conf. Level
Raw            -0.3889 0.3203 [-0.9353, 0.1575]         0.9
Hedges's g(z)  -0.2268 0.1952 [-0.5363, 0.0869]         0.9
Note: SMD confidence intervals are an approximation. See vignette("SMD_calcs").
t_TOST(mean_StudyTime ~ condsFile, data = study_time_FR, paired = TRUE,
       eqb = 0.4, eqbound_type = "SMD")
Warning: setting bound type to SMD produces biased results!

Paired t-test

The equivalence test was non-significant, t(26) = -0.33, p = 0.63
The null hypothesis test was significant, t(26) = -2.41, p = 0.02
NHST: reject null significance hypothesis that the effect is equal to zero 
TOST: don't reject null equivalence hypothesis

TOST Results 
                 t df p.value
t-test     -2.4071 26   0.023
TOST Lower -0.3286 26   0.627
TOST Upper -4.4856 26 < 0.001

Effect Sizes 
              Estimate     SE               C.I. Conf. Level
Raw            -1.5540 0.6456 [-2.6551, -0.4529]         0.9
Hedges's g(z)  -0.4497 0.2030 [-0.7695, -0.1219]         0.9
Note: SMD confidence intervals are an approximation. See vignette("SMD_calcs").

Hypothesis 2

Hypothesis: When allowed to choose how many attempts to make, participants will tend to be overly conservative and therefore underperform. Given this, if participants are obliged to respond despite their risk aversion, memory usage (MU) will increase. We predict then that, across all conditions, MU(total) (as measured in Total-response trials) will be higher than MU(free) (as measured in Free-response trials). Further, we expect an interaction, with this difference being larger in the maintenance-delay condition and smaller in the sampling-delay condition.

Test: Multiple regression (lmer) TOSTER

All_conditions <- data1 %>%
  group_by(participant, condsFile) %>%
  filter(!condsFile == "no_cost") %>%
  filter(!condsFile == "no_costClosing") %>%
  summarize(mean_MU = mean(meanMU, na.rm = TRUE),
            mean_StudyTime = mean(meanListTime, na.rm = TRUE), 
            .groups = 'drop')

All_conditions <- All_conditions %>%
  mutate(conditionType = ifelse(grepl("Closing", condsFile), "TotalResponse", "FreeResponse"))

All_conditions <- All_conditions %>%
  mutate(condsFileSimplified = ifelse(grepl("maintenance", condsFile), "maintenance", "sampling"))

library(lme4)
Loading required package: Matrix

Attaching package: 'Matrix'
The following objects are masked from 'package:tidyr':

    expand, pack, unpack
library(lmerTest)

Attaching package: 'lmerTest'
The following object is masked from 'package:lme4':

    lmer
The following object is masked from 'package:stats':

    step
library(negligible)

hypothesis2 <- lmer(mean_MU ~ conditionType + condsFileSimplified + 
                      condsFileSimplified*conditionType + (1 | participant),
                    All_conditions)

lower <- contest1D(hypothesis2, c(0, 1, 0, 0), confint=TRUE, rhs=-0.4) # get t value for test against lower bound
upper <- contest1D(hypothesis2, c(0, 1, 0, 0), confint=TRUE, rhs=0.4) # get t value for test against upper bound

print("Below is the lower bound:")
[1] "Below is the lower bound:"
lower$`Pr(>|t|)`/2  # test against lower bound
[1] 0.003206353
print("Below is the upper bound:")
[1] "Below is the upper bound:"
upper$`Pr(>|t|)`/2  # test against upper bound
[1] 0.1019836

Hypothesis 3

Hypothesis: From our work and work from other labs, we anticipate (alongside our main effects) that there to be considerable individual variation in MU. There are two factors relevant to memory usage that can underlie this, differences in working memory capacity (here, the relative ease with which a certain number of list items can be encoded and maintained in memory) and differences in effort (here, the time and cognitive effort one is willing to devote toward the encoding and maintenance of memory). If individual differences in MU are driven largely by differences in capacity, with participants exerting similar effort levels, we should see a strong relationship between study time and MU, but a relatively weak association between TEPR and MU. We hypothesize, instead, that individual differences in MU are driven largely by differences in effort, with participants coming to the task with similar memory capacity. We expect individual participants to differ in their disposition towards completing the task, such that they will tend toward either “loading up” internal memory during their first trip (heavy loaders) or balancing their memory usage out across multiple trips (light lifters). This predicts a strong relationship between both study time and TEPR with MU. However, since TEPR and study time are both driven by the same underlying variable - effort (i.e. greater effort manifests both as longer study time to ‘load up’ on more items and, consequentially, greater TEPR to maintain that larger load) - we expect that TEPR will not account for a substantial additional variance over and above that accounted for by study time. We hypothesize that most of this difference can be accounted for by differences in relative effort.

Test: Multiple regression (lmer) TOSTER

hypothesis3 <- lmer(mean_MU ~ mean_StudyTime + avg_pupil +
             (1 | participant), 
           merged_data)

lower <- contest1D(hypothesis3, c(0, 0, 1), confint=TRUE, rhs=-0.4) 
upper <- contest1D(hypothesis3, c(0, 0, 1), confint=TRUE, rhs=0.4)

print("Below is the lower bound:")
[1] "Below is the lower bound:"
lower$`Pr(>|t|)`/2  # test against lower bound
[1] 0.02837602
print("Below is the upper bound:")
[1] "Below is the upper bound:"
upper$`Pr(>|t|)`/2  # test against upper bound
[1] 0.2076068

Diagnostic check: Variance inflation (VIF) score for study time and pupil. They will be identical, but we should check it.

library(car)
Loading required package: carData

Attaching package: 'car'
The following object is masked from 'package:dplyr':

    recode
The following object is masked from 'package:purrr':

    some
library(performance)

plot(hypothesis3, which = 1, main = "Model Fit")

vif_h3 <- vif(hypothesis3)
vif_h3 
mean_StudyTime      avg_pupil 
      1.009536       1.009536 

Correlation check: TOSTER Kendall correlations. Only MU and Study time are significantly correlated. The slight negative correlation between pupil and study time suggest super long study times are participants “taking their time” to remember them all, which might be less effortful than trying to remember them all in shorter periods of time.

library(TOSTER)
  
z_cor_test(merged_data$mean_StudyTime[complete.cases(merged_data$mean_StudyTime, merged_data$avg_pupil)],
           merged_data$avg_pupil[complete.cases(merged_data$mean_StudyTime, merged_data$avg_pupil)],
           method = "kendall")

    Kendall's rank correlation tau

data:  merged_data$mean_StudyTime[complete.cases(merged_data$mean_StudyTime,  and merged_data$avg_pupil[complete.cases(merged_data$mean_StudyTime,     merged_data$avg_pupil)] and     merged_data$avg_pupil)]
z = -1.0805, N = 102, p-value = 0.2799
alternative hypothesis: true tau is not equal to 0
95 percent confidence interval:
 -0.20028604  0.05866353
sample estimates:
        tau 
-0.07202485 
z_cor_test(merged_data$mean_MU[complete.cases(merged_data$mean_MU, merged_data$avg_pupil)],
           merged_data$avg_pupil[complete.cases(merged_data$mean_MU, merged_data$avg_pupil)],
           method = "kendall")

    Kendall's rank correlation tau

data:  merged_data$mean_MU[complete.cases(merged_data$mean_MU, merged_data$avg_pupil)] and merged_data$avg_pupil[complete.cases(merged_data$mean_MU, merged_data$avg_pupil)]
z = 0.26366, N = 102, p-value = 0.792
alternative hypothesis: true tau is not equal to 0
95 percent confidence interval:
 -0.1127925  0.1474053
sample estimates:
       tau 
0.01760445 
z_cor_test(merged_data$mean_MU[complete.cases(merged_data$mean_MU, merged_data$mean_StudyTime)],
           merged_data$mean_StudyTime[complete.cases(merged_data$mean_MU, merged_data$mean_StudyTime)],
           method = "kendall")

    Kendall's rank correlation tau

data:  merged_data$mean_MU[complete.cases(merged_data$mean_MU, merged_data$mean_StudyTime)] and merged_data$mean_StudyTime[complete.cases(merged_data$mean_MU, merged_data$mean_MU[complete.cases(merged_data$mean_MU, merged_data$mean_StudyTime)] and     merged_data$mean_StudyTime)]
z = 7.2648, N = 108, p-value = 0.0000000000003737
alternative hypothesis: true tau is not equal to 0
95 percent confidence interval:
 0.3309279 0.5356024
sample estimates:
      tau 
0.4389417 
library(ggplot2)

ggplot(merged_data, aes(x = mean_StudyTime, y = avg_pupil)) +
  geom_point(color = "blue", alpha = 0.6) +  # Scatter points
  geom_smooth(method = "lm", color = "red", se = FALSE) +  # Linear trend line
  labs(title = "Correlation between Study Time and Pupil Dilation",
       x = "Average Study Time",
       y = "Average Pupil Dilation") +
  theme_minimal()
`geom_smooth()` using formula = 'y ~ x'

ggplot(merged_data, aes(x = mean_MU, y = avg_pupil)) +
  geom_point(color = "blue", alpha = 0.6) +  # Scatter points
  geom_smooth(method = "lm", color = "red", se = FALSE) +  # Linear trend line
  labs(title = "Correlation between MU and Pupil Dilation",
       x = "Average MU",
       y = "Average Pupil Dilation") +
  theme_minimal()
`geom_smooth()` using formula = 'y ~ x'

ggplot(merged_data, aes(x = mean_MU, y = mean_StudyTime)) +
  geom_point(color = "blue", alpha = 0.6) +  # Scatter points
  geom_smooth(method = "lm", color = "red", se = FALSE) +  # Linear trend line
  labs(title = "Correlation between MU and Study time",
       x = "Average MU",
       y = "Average study time") +
  theme_minimal()
`geom_smooth()` using formula = 'y ~ x'

Hypothesis 4

Hypothesis: We have included a Mental Calculation task to validate our pupillometry pipeline. There are two conditions, easy and hard. Since performing mental arithmetic consistently results in pupil dilations that increase with the difficulty of the arithmetic task (Borys et al., 2017; Marquart & de Winter, 2015), we expect that we will find a larger pupil dilation for “hard” compared to “easy” math problems during the period that participants are performing the mental calculation. We expect the TEPR to be larger in the hard math problems.

Test: paired TOSTER t-test

# Prepare data --------------------
MC_data <- read_csv("scripts_and_data/processed_data/MC_ET_preprocessed_step2.csv",
                    show_col_types = F)

MC_data <- MC_data %>%
  mutate(difficulty = ifelse(trial %% 2 == 1, "hard", "easy"))

# Make a frame counter for each trial
MC_data <- MC_data %>%
  group_by(participant, condsFile, trial) %>%
  mutate(counter = row_number()) %>%
  ungroup()

# get avg value for pupil
pupil_data_MC <- MC_data %>%
  filter(counter >= 60 & counter <= 240) %>%  # 1 - 4s
  group_by(participant, difficulty) %>%
  summarise(avg_pupil = mean(change_from_baseline, na.rm = TRUE),
            .groups = "drop")

# TOSTER test -----------------------

t_TOST(avg_pupil ~ difficulty, data = pupil_data_MC, paired = TRUE,
       eqb = 0.4, eqbound_type = "SMD")
Warning: setting bound type to SMD produces biased results!

Paired t-test

The equivalence test was non-significant, t(25) = -4, p = 1
The null hypothesis test was significant, t(25) = -5.99, p < 0.01
NHST: reject null significance hypothesis that the effect is equal to zero 
TOST: don't reject null equivalence hypothesis

TOST Results 
                t df p.value
t-test     -5.993 25 < 0.001
TOST Lower -3.953 25       1
TOST Upper -8.032 25 < 0.001

Effect Sizes 
              Estimate     SE               C.I. Conf. Level
Raw            -0.2631 0.0439 [-0.3381, -0.1881]         0.9
Hedges's g(z)  -1.1396 0.2576 [-1.5402, -0.7219]         0.9
Note: SMD confidence intervals are an approximation. See vignette("SMD_calcs").