df %>% select(RT, Condition, Session, Cue) %>% group_by(Condition, Session, Cue) %>%
summarise(across(everything(), list(mean = mean, sd = sd, min = min, max = max)))
## `summarise()` has grouped output by 'Condition', 'Session'. You can override
## using the `.groups` argument.
## # A tibble: 36 × 7
## # Groups: Condition, Session [18]
## Condition Session Cue RT_mean RT_sd RT_min RT_max
## <chr> <fct> <fct> <dbl> <dbl> <dbl> <dbl>
## 1 A 1 opioid 623. 210. 339 1447
## 2 A 1 pain 635. 213. 317 1440
## 3 A 2 opioid 580. 144. 207 1295
## 4 A 2 pain 576. 151. 367 1356
## 5 A 3 opioid 557. 125. 207 1167
## 6 A 3 pain 562. 133. 312 1316
## 7 A 4 opioid 551. 140. 342 1348
## 8 A 4 pain 552. 144. 328 1241
## 9 A 5 opioid 536. 141. 301 1217
## 10 A 5 pain 534. 137. 322 1219
## # … with 26 more rows
-Code for AB calculations hidden
-Attentional Bias Metrics Per Subject, Condition, Session, & Cue
By_Subject_Output
## # A tibble: 268 × 10
## # Groups: Subject, Condition, Session [134]
## Subject Condition Session Cue Mean_Bias Mean_Toward Mean_Away Peak_Toward
## <dbl> <chr> <fct> <fct> <dbl> <dbl> <dbl> <dbl>
## 1 56001 C 1 opioid 6.24 97.9 103. 442
## 2 56001 C 1 pain 33.2 139. 61.2 429
## 3 56001 C 2 opioid 12.3 114. 110. 402
## 4 56001 C 2 pain 0.776 100. 107. 380
## 5 56001 A 3 opioid 22.9 115. 113. 350
## 6 56001 A 3 pain 4.97 65.3 89.6 228
## 7 56001 A 4 opioid -39.8 82.1 106. 240
## 8 56001 A 4 pain 1.86 75.7 101. 326
## 9 56001 B 5 opioid -0.504 88.8 65.7 251
## 10 56001 B 5 pain 9.94 110. 52.1 305
## # … with 258 more rows, and 2 more variables: Peak_Away <dbl>,
## # Variability <dbl>
By_Condition_Output
## # A tibble: 36 × 9
## # Groups: Condition, Session [18]
## Condition Session Cue Mean_Bias Mean_Toward Mean_Away Peak_Toward Peak_Away
## <chr> <fct> <fct> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 A 1 opio… -4.88 112. 117. 323. 317.
## 2 A 1 pain 1.90 117. 125. 400. 353.
## 3 B 1 opio… -3.52 95.1 90.3 318. 313.
## 4 B 1 pain 6.39 84.6 90.5 292. 290.
## 5 C 1 opio… -9.58 119. 128. 364. 367.
## 6 C 1 pain 5.10 130. 118. 396. 386.
## 7 A 2 opio… 20.0 102. 96.6 317. 329.
## 8 A 2 pain -10.2 93.9 105. 354. 341.
## 9 B 2 opio… 3.00 106. 109. 406. 331.
## 10 B 2 pain 28.8 117. 96.1 364. 299.
## # … with 26 more rows, and 1 more variable: Variability <dbl>
By_Session_Output
## # A tibble: 12 × 8
## # Groups: Session [6]
## Session Cue Mean_Bias Mean_Toward Mean_Away Peak_Toward Peak_Away
## <fct> <fct> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 opioid -6.27 109. 113. 337. 335.
## 2 1 pain 4.50 113. 112. 366. 347.
## 3 2 opioid 1.82 108. 110. 357. 341.
## 4 2 pain 6.25 110. 112. 359. 342.
## 5 3 opioid -0.233 111. 108. 373. 364.
## 6 3 pain -4.52 105. 111. 338. 353.
## 7 4 opioid 4.76 111. 110. 377. 352.
## 8 4 pain 2.01 110. 106. 343. 362.
## 9 5 opioid -3.19 106. 105. 324. 348.
## 10 5 pain -13.3 103. 107. 326. 342.
## 11 6 opioid -3.74 105. 110. 335. 329.
## 12 6 pain -12.3 106. 116. 313. 348.
## # … with 1 more variable: Variability <dbl>
By_Cue_Output
## # A tibble: 2 × 7
## Cue Mean_Bias Mean_Toward Mean_Away Peak_Toward Peak_Away Variability
## <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 opioid -1.01 108. 110. 352. 345. 94.2
## 2 pain -1.76 108. 111. 343. 349. 94.7
-Changing session variable to represent just pre-post
df$Session[df$Session == 3] <- 1
df$Session[df$Session == 5] <- 1
df$Session[df$Session == 4] <- 2
df$Session[df$Session == 6] <- 2
df$Session <- droplevels(factor(df$Session, levels = c(1:6), labels = c("Pre", "Post", "3", "4", "5", "6")))
table(df$Subject, df$Session, df$Condition)
## , , = A
##
##
## Pre Post
## 56001 143 146
## 56002 159 158
## 56003 0 0
## 56004 155 151
## 56005 159 157
## 56006 156 157
## 56007 159 144
## 56008 155 157
## 56009 158 154
## 56010 153 158
## 56011 0 0
## 56012 157 158
## 56013 0 0
## 56014 0 0
## 56015 0 150
## 56016 133 152
## 56017 152 152
## 56018 0 0
## 56019 148 151
## 56020 155 154
## 56021 154 154
## 56022 0 0
## 56023 147 141
## 56025 159 153
## 56026 159 155
## 56027 154 148
## 56028 0 0
##
## , , = B
##
##
## Pre Post
## 56001 146 149
## 56002 0 155
## 56003 158 0
## 56004 155 153
## 56005 140 156
## 56006 159 141
## 56007 137 141
## 56008 156 157
## 56009 158 158
## 56010 155 158
## 56011 147 148
## 56012 155 151
## 56013 0 0
## 56014 132 146
## 56015 150 145
## 56016 156 144
## 56017 0 0
## 56018 138 96
## 56019 137 152
## 56020 133 118
## 56021 142 153
## 56022 144 148
## 56023 157 156
## 56025 159 153
## 56026 144 158
## 56027 155 148
## 56028 157 153
##
## , , = C
##
##
## Pre Post
## 56001 152 147
## 56002 147 159
## 56003 148 139
## 56004 157 153
## 56005 157 158
## 56006 157 157
## 56007 156 150
## 56008 153 154
## 56009 154 146
## 56010 152 153
## 56011 149 155
## 56012 159 156
## 56013 149 123
## 56014 130 0
## 56015 150 159
## 56016 154 156
## 56017 0 0
## 56018 0 0
## 56019 154 156
## 56020 155 155
## 56021 152 155
## 56022 153 155
## 56023 0 0
## 56025 153 158
## 56026 151 126
## 56027 139 128
## 56028 156 153
-Something to note: There are several subjects who appear to have no data for at least Condition/1 time-point:
Folks Missing 1 pre/post data point: #Condition A: 15 #Condition B: 02 #Condition C: 14
Folks Missing both pre/post data points #Condition A: 03, 11, 13, 14, 18, 22, 28 #Condition B: 03, 13, 17 #Condition C: 17,18,23
R seems to be dropping these folks from ANOVA analysis below. I’m trying to specify a way for them to be kept and not succeeding at the moment, but even if I can, that still is going to result with at least 13/28 getting dropped. A REALLY small sample of N=15 at best or N=12 at worst.
-Changing Data into Long Format
df_long <- df %>% select(Subject, Condition, Session, Cue, mean_bias:variability) %>%
pivot_longer(cols = c(mean_bias:variability), names_to = "Bias_Type", values_to = "RT")
#DV = Mean Bias
df_long_opioid_mean_bias <- df_long %>% filter(Cue == "opioid" & Bias_Type == "mean_bias")
afex::aov_car(formula = RT ~ Session*Condition + Error(Subject/Session*Condition), data = df_long_opioid_mean_bias,
type = 3, na.rm = T)
## Warning: More than one observation per design cell, aggregating data using `fun_aggregate = mean`.
## To turn off this warning, pass `fun_aggregate = mean` explicitly.
## Warning: Missing values for following ID(s):
## 56002, 56003, 56011, 56013, 56014, 56015, 56017, 56018, 56022, 56023, 56028
## Removing those cases from the analysis.
## Anova Table (Type 3 tests)
##
## Response: RT
## Effect df MSE F ges p.value
## 1 Session 1, 15 1730.29 0.70 .017 .417
## 2 Condition 1.87, 28.00 674.69 0.72 .013 .487
## 3 Session:Condition 1.71, 25.58 599.62 1.92 .027 .171
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
#DV = Mean Away
df_long_opioid_mean_away <- df_long %>% filter(Cue == "opioid" & Bias_Type == "mean_away")
afex::aov_car(formula = RT ~ Session*Condition + Error(Subject/Session*Condition), data = df_long_opioid_mean_away,
type = 3, na.rm = T)
## Warning: More than one observation per design cell, aggregating data using `fun_aggregate = mean`.
## To turn off this warning, pass `fun_aggregate = mean` explicitly.
## Warning: Missing values for following ID(s):
## 56002, 56003, 56011, 56013, 56014, 56015, 56017, 56018, 56022, 56023, 56028
## Removing those cases from the analysis.
## Anova Table (Type 3 tests)
##
## Response: RT
## Effect df MSE F ges p.value
## 1 Session 1, 15 1084.77 2.34 .010 .147
## 2 Condition 1.48, 22.25 1281.37 0.86 .007 .406
## 3 Session:Condition 1.98, 29.77 373.76 0.42 .001 .660
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
#DV = Mean Toward
df_long_opioid_mean_toward <- df_long %>% filter(Cue == "opioid" & Bias_Type == "mean_toward")
afex::aov_car(formula = RT ~ Session*Condition + Error(Subject/Session*Condition), data = df_long_opioid_mean_toward,
type = 3, na.rm = T)
## Warning: More than one observation per design cell, aggregating data using `fun_aggregate = mean`.
## To turn off this warning, pass `fun_aggregate = mean` explicitly.
## Warning: Missing values for following ID(s):
## 56002, 56003, 56011, 56013, 56014, 56015, 56017, 56018, 56022, 56023, 56028
## Removing those cases from the analysis.
## Anova Table (Type 3 tests)
##
## Response: RT
## Effect df MSE F ges p.value
## 1 Session 1, 15 331.77 1.33 .002 .266
## 2 Condition 1.83, 27.44 1097.91 0.65 .007 .515
## 3 Session:Condition 1.20, 18.06 1727.81 0.21 .002 .696
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
#DV = Peak Away
df_long_opioid_peak_away <- df_long %>% filter(Cue == "opioid" & Bias_Type == "peak_away")
afex::aov_car(formula = RT ~ Session*Condition + Error(Subject/Session*Condition), data = df_long_opioid_peak_away,
type = 3, na.rm = T)
## Warning: More than one observation per design cell, aggregating data using `fun_aggregate = mean`.
## To turn off this warning, pass `fun_aggregate = mean` explicitly.
## Warning: Missing values for following ID(s):
## 56002, 56003, 56011, 56013, 56014, 56015, 56017, 56018, 56022, 56023, 56028
## Removing those cases from the analysis.
## Anova Table (Type 3 tests)
##
## Response: RT
## Effect df MSE F ges p.value
## 1 Session 1, 15 5111.51 1.17 .002 .296
## 2 Condition 1.64, 24.59 16820.23 0.80 .007 .438
## 3 Session:Condition 1.72, 25.80 7437.94 0.00 <.001 .993
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
#DV = Peak Toward
df_long_opioid_peak_toward <- df_long %>% filter(Cue == "opioid" & Bias_Type == "peak_toward")
afex::aov_car(formula = RT ~ Session*Condition + Error(Subject/Session*Condition), data = df_long_opioid_peak_toward,
type = 3, na.rm = T)
## Warning: More than one observation per design cell, aggregating data using `fun_aggregate = mean`.
## To turn off this warning, pass `fun_aggregate = mean` explicitly.
## Warning: Missing values for following ID(s):
## 56002, 56003, 56011, 56013, 56014, 56015, 56017, 56018, 56022, 56023, 56028
## Removing those cases from the analysis.
## Anova Table (Type 3 tests)
##
## Response: RT
## Effect df MSE F ges p.value
## 1 Session 1, 15 7247.98 3.83 + .012 .069
## 2 Condition 1.62, 24.32 11543.84 0.13 <.001 .840
## 3 Session:Condition 1.20, 17.99 19441.12 0.25 .002 .668
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
#DV = Variability
df_long_opioid_variability <- df_long %>% filter(Cue == "opioid" & Bias_Type == "variability")
afex::aov_car(formula = RT ~ Session*Condition + Error(Subject/Session*Condition), data = df_long_opioid_variability,
type = 3, na.rm = T)
## Warning: More than one observation per design cell, aggregating data using `fun_aggregate = mean`.
## To turn off this warning, pass `fun_aggregate = mean` explicitly.
## Warning: Missing values for following ID(s):
## 56002, 56003, 56011, 56013, 56014, 56015, 56017, 56018, 56022, 56023, 56028
## Removing those cases from the analysis.
## Anova Table (Type 3 tests)
##
## Response: RT
## Effect df MSE F ges p.value
## 1 Session 1, 15 305.22 1.86 .004 .192
## 2 Condition 1.86, 27.85 623.94 0.82 .006 .441
## 3 Session:Condition 1.89, 28.32 283.68 0.62 .002 .534
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
#DV = Mean Bias
df_long_pain_mean_bias <- df_long %>% filter(Cue == "pain" & Bias_Type == "mean_bias")
afex::aov_car(formula = RT ~ Session*Condition + Error(Subject/Session*Condition), data = df_long_pain_mean_bias,
type = 3, na.rm = T)
## Warning: More than one observation per design cell, aggregating data using `fun_aggregate = mean`.
## To turn off this warning, pass `fun_aggregate = mean` explicitly.
## Warning: Missing values for following ID(s):
## 56002, 56003, 56011, 56013, 56014, 56015, 56017, 56018, 56022, 56023, 56028
## Removing those cases from the analysis.
## Anova Table (Type 3 tests)
##
## Response: RT
## Effect df MSE F ges p.value
## 1 Session 1, 15 899.92 0.37 .005 .552
## 2 Condition 1.27, 19.02 1477.83 0.28 .009 .657
## 3 Session:Condition 1.80, 26.94 418.87 0.17 .002 .825
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
#DV = Mean Away
df_long_pain_mean_away <- df_long %>% filter(Cue == "pain" & Bias_Type == "mean_away")
afex::aov_car(formula = RT ~ Session*Condition + Error(Subject/Session*Condition), data = df_long_pain_mean_away,
type = 3, na.rm = T)
## Warning: More than one observation per design cell, aggregating data using `fun_aggregate = mean`.
## To turn off this warning, pass `fun_aggregate = mean` explicitly.
## Warning: Missing values for following ID(s):
## 56002, 56003, 56011, 56013, 56014, 56015, 56017, 56018, 56022, 56023, 56028
## Removing those cases from the analysis.
## Anova Table (Type 3 tests)
##
## Response: RT
## Effect df MSE F ges p.value
## 1 Session 1, 15 697.86 1.10 .003 .310
## 2 Condition 1.66, 24.90 1342.32 0.07 <.001 .899
## 3 Session:Condition 1.51, 22.72 809.59 0.07 <.001 .881
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
#DV = Mean Toward
df_long_pain_mean_toward <- df_long %>% filter(Cue == "pain" & Bias_Type == "mean_toward")
afex::aov_car(formula = RT ~ Session*Condition + Error(Subject/Session*Condition), data = df_long_pain_mean_toward,
type = 3, na.rm = T)
## Warning: More than one observation per design cell, aggregating data using `fun_aggregate = mean`.
## To turn off this warning, pass `fun_aggregate = mean` explicitly.
## Warning: Missing values for following ID(s):
## 56002, 56003, 56011, 56013, 56014, 56015, 56017, 56018, 56022, 56023, 56028
## Removing those cases from the analysis.
## Anova Table (Type 3 tests)
##
## Response: RT
## Effect df MSE F ges p.value
## 1 Session 1, 15 1623.54 0.22 .002 .643
## 2 Condition 1.91, 28.68 845.07 1.05 .008 .359
## 3 Session:Condition 1.69, 25.36 433.06 0.60 .002 .527
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
#DV = Peak Away
df_long_pain_peak_away <- df_long %>% filter(Cue == "pain" & Bias_Type == "peak_away")
afex::aov_car(formula = RT ~ Session*Condition + Error(Subject/Session*Condition), data = df_long_pain_peak_away,
type = 3, na.rm = T)
## Warning: More than one observation per design cell, aggregating data using `fun_aggregate = mean`.
## To turn off this warning, pass `fun_aggregate = mean` explicitly.
## Warning: Missing values for following ID(s):
## 56002, 56003, 56011, 56013, 56014, 56015, 56017, 56018, 56022, 56023, 56028
## Removing those cases from the analysis.
## Anova Table (Type 3 tests)
##
## Response: RT
## Effect df MSE F ges p.value
## 1 Session 1, 15 10744.89 1.46 .006 .246
## 2 Condition 1.98, 29.73 6103.29 0.37 .002 .693
## 3 Session:Condition 1.55, 23.30 9044.77 0.71 .004 .468
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
#DV = Peak Toward
df_long_pain_peak_toward <- df_long %>% filter(Cue == "pain" & Bias_Type == "peak_toward")
afex::aov_car(formula = RT ~ Session*Condition + Error(Subject/Session*Condition), data = df_long_pain_peak_toward,
type = 3, na.rm = T)
## Warning: More than one observation per design cell, aggregating data using `fun_aggregate = mean`.
## To turn off this warning, pass `fun_aggregate = mean` explicitly.
## Warning: Missing values for following ID(s):
## 56002, 56003, 56011, 56013, 56014, 56015, 56017, 56018, 56022, 56023, 56028
## Removing those cases from the analysis.
## Anova Table (Type 3 tests)
##
## Response: RT
## Effect df MSE F ges p.value
## 1 Session 1, 15 12315.63 0.04 <.001 .853
## 2 Condition 1.32, 19.84 14603.39 0.45 .004 .562
## 3 Session:Condition 1.35, 20.18 5994.07 0.31 .001 .649
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG
#DV = Variability
df_long_pain_variability <- df_long %>% filter(Cue == "pain" & Bias_Type == "variability")
afex::aov_car(formula = RT ~ Session*Condition + Error(Subject/Session*Condition), data = df_long_pain_variability,
type = 3, na.rm = T)
## Warning: More than one observation per design cell, aggregating data using `fun_aggregate = mean`.
## To turn off this warning, pass `fun_aggregate = mean` explicitly.
## Warning: Missing values for following ID(s):
## 56002, 56003, 56011, 56013, 56014, 56015, 56017, 56018, 56022, 56023, 56028
## Removing those cases from the analysis.
## Anova Table (Type 3 tests)
##
## Response: RT
## Effect df MSE F ges p.value
## 1 Session 1, 15 646.84 0.46 .002 .510
## 2 Condition 1.96, 29.36 390.98 0.80 .004 .457
## 3 Session:Condition 1.85, 27.72 370.63 0.04 <.001 .950
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '+' 0.1 ' ' 1
##
## Sphericity correction method: GG