1. JP Data

-Note: Large chunks of code have been hidden to improve readibility. ## 1. Load Packages Used in Data Analysis -Code hidden

2. Data Read-In

-Code hidden

3. Data Pre-processing

Creating Trial Number Column

length(df$Session[df$Subject == 56001 & df$Session == 1]) #160 rows ("trials") per part.
## [1] 160
dim(df) #21,440 total rows ("trials")
## [1] 21440     8
21440/160 #160 rows repeated 134 times
## [1] 134
df$Trial <- rep(seq(1:160), 134) #Code creates a sequence of 1-160, per participant per session, and stores this in the "Trial" variable

Probe accuracy, incorrect trials, improbable reaction times

-The code below when run illustrates that there are no administrations #With <50% accuracy. Nothing excluded here.

df %>% 
  group_by(Subject, Session, Cue) %>% 
  summarise(Percent_Accurate = mean(Accuracy)) %>% 
  filter(Percent_Accurate < 0.50) 
## `summarise()` has grouped output by 'Subject', 'Session'. You can override
## using the `.groups` argument.
## # A tibble: 0 × 4
## # Groups:   Subject, Session [0]
## # … with 4 variables: Subject <dbl>, Session <fct>, Cue <fct>,
## #   Percent_Accurate <dbl>

-The code below indicates the overall # of trials and the counts/percents for 1) incorrect trials to be excluded, and 2) improbable reaction time trials (i.e., <200ms OR >1500ms) to be excluded. The code immediately following then excludes this data.

df %>% 
  group_by(Session) %>% 
  summarise(Overall_Trials = n(), #Overall trial counts
            Count_Inc_Trial = sum(ifelse(Accuracy == 0,1,0)), #Incorrect trial count
            Per_Inc_Trial = 1 - mean(Accuracy), #Percent of trials that are incorrect
            Count_Inc_RT = sum(ifelse(RT < 200 | RT > 1500, 1, 0)), 
            #Count of trials whose reaction times are < 200 or > 1500
            Per_Inc_RT = 1 - mean(ifelse(RT < 200 | RT > 1500, 0, 1)))
## # A tibble: 6 × 6
##   Session Overall_Trials Count_Inc_Trial Per_Inc_Trial Count_Inc_RT Per_Inc_RT
##   <fct>            <int>           <dbl>         <dbl>        <dbl>      <dbl>
## 1 1                 4160              84        0.0202           79     0.0190
## 2 2                 4160             161        0.0387           80     0.0192
## 3 3                 3680              60        0.0163           70     0.0190
## 4 4                 3680              82        0.0223           62     0.0168
## 5 5                 2880              71        0.0247           69     0.0240
## 6 6                 2880              74        0.0257           90     0.0312

-Filtering out improbable reaction times

df <- df %>% 
  filter(Accuracy == 1) %>%  #Exclude incorrect trials
  filter(RT > 200 & RT < 1500) #Exclude RT's <200ms or >1500ms

-Maximum & Minimum RT after exclusions

max(df$RT)
## [1] 1499
min(df$RT)
## [1] 207

-Code for Median Absolute Deviation and SD calculations for Reaction Times hidden

-MAD & SD Calculation Results

df %>% 
  group_by(Session) %>% 
  summarise(Ovr_Trl_Aftr_Exc = n(), #Overall trial counts after excluding for above-noted criteria
            Count_MAD3_Over = sum(ifelse(RT > MAD_Exclude_Score, 1,0)), #Count of trials that had RT > 3MAD above individual median
            Per_MAD3_Over = mean(ifelse(RT > MAD_Exclude_Score, 1, 0)),
            Count_SD3_Over = sum(ifelse(RT > SD_Exclude_Score, 1,0)), #Count of trials that had RT > 3MAD above individual median
            Per_SD3_Over = mean(ifelse(RT > SD_Exclude_Score, 1, 0)))
## # A tibble: 6 × 6
##   Session Ovr_Trl_Aftr_Exc Count_MAD3_Over Per_MAD3_Over Count_SD3_Over
##   <fct>              <int>           <dbl>         <dbl>          <dbl>
## 1 1                   4005             205        0.0512             79
## 2 2                   3931             138        0.0351             54
## 3 3                   3551             115        0.0324             47
## 4 4                   3538             119        0.0336             50
## 5 5                   2746             114        0.0415             54
## 6 6                   2725             128        0.0470             52
## # … with 1 more variable: Per_SD3_Over <dbl>

-Excluding Folks based on SD for Reaction Times

df <- df %>% 
  filter(RT < SD_Exclude_Score) #Exclude folks whose RT are >3SD above their individual means

3. Descriptive Statistics

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

4. Attentional Bias (AB) Calculations

-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

5. ANOVA’s

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

6. Opioid Cue ANOVAs

6a. Opioid Mean Bias

#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

6b. Opioid Mean Away

#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

6c. Opioid Mean Toward

#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

6d. Opioid Peak Away

#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

6e. Opioid Peak Toward

#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

6f. Opioid Variability

#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

7. Pain Cue ANOVAs

7a. Pain Mean Bias

#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

7b. Pain Mean Away

#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

7c. Pain Mean Toward

#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

7d. Pain Peak Away

#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

7e. Pain Peak Toward

#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

7f. Pain Variability

#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

8. Muiltilevel Models

8a. Opioid Mean Bias

#DV = Mean Bias
#reANOVA
re_O_MB <- lmer(RT ~ (1|Subject), data = df_long_opioid_mean_bias)
performance::icc(re_O_MB)
## # Intraclass Correlation Coefficient
## 
##      Adjusted ICC: 0.315
##   Conditional ICC: 0.315
MLM_O_MB <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_opioid_mean_bias)
summary(MLM_O_MB)
## Linear mixed model fit by REML ['lmerMod']
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
##    Data: df_long_opioid_mean_bias
## 
## REML criterion at convergence: 88186.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8421 -0.5188 -0.0156  0.4733  4.0205 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  Subject  (Intercept)  644.9   25.40         
##           SessionPost 1131.8   33.64    -0.76
##  Residual              355.0   18.84         
## Number of obs: 10092, groups:  Subject, 27
## 
## Fixed effects:
##                        Estimate Std. Error t value
## (Intercept)             -3.3042     4.9167  -0.672
## SessionPost              6.1505     6.5184   0.944
## ConditionB              10.3078     0.7085  14.548
## ConditionC              -4.0348     0.7063  -5.712
## SessionPost:ConditionB -14.5469     0.9898 -14.697
## SessionPost:ConditionC   0.7019     0.9952   0.705
## 
## Correlation of Fixed Effects:
##             (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.755                            
## ConditionB  -0.083  0.062                     
## ConditionC  -0.083  0.062  0.581              
## SssnPst:CnB  0.059 -0.086 -0.716 -0.416       
## SssnPst:CnC  0.059 -0.086 -0.413 -0.710  0.562
p1 <- ggplot(df_long_opioid_mean_bias, aes(x=Session,y=RT, col = Condition)) +
  stat_summary(fun.data = "mean_cl_boot")

p2 <- ggplot(df_long_opioid_mean_bias, aes(x=Session,y=RT, col = Condition, group=Subject)) +
  geom_point(alpha = .03) + geom_line(alpha = .5)

cowplot::plot_grid(p1, p2, labels = c('Means', 'Individual Trajectories'), label_size = 12)

8b. Opioid Mean Bias Away

#DV = Mean Away
#reANOVA
re_O_MA <- lmer(RT ~ (1|Subject), data = df_long_opioid_mean_away)
performance::icc(re_O_MA)
## # Intraclass Correlation Coefficient
## 
##      Adjusted ICC: 0.717
##   Conditional ICC: 0.717
MLM_O_MA <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_opioid_mean_away)
summary(MLM_O_MA)
## Linear mixed model fit by REML ['lmerMod']
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
##    Data: df_long_opioid_mean_away
## 
## REML criterion at convergence: 91513.2
## 
## Scaled residuals: 
##      Min       1Q   Median       3Q      Max 
## -2.91909 -0.52506 -0.01082  0.44187  2.78297 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  Subject  (Intercept) 2098.2   45.81         
##           SessionPost 1842.3   42.92    -0.15
##  Residual              491.5   22.17         
## Number of obs: 10092, groups:  Subject, 27
## 
## Fixed effects:
##                        Estimate Std. Error t value
## (Intercept)            114.5473     8.8380  12.961
## SessionPost             -2.3229     8.3082  -0.280
## ConditionB             -11.1164     0.8337 -13.334
## ConditionC               1.1985     0.8311   1.442
## SessionPost:ConditionB  13.8782     1.1646  11.917
## SessionPost:ConditionC  11.0236     1.1710   9.414
## 
## Correlation of Fixed Effects:
##             (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.152                            
## ConditionB  -0.054  0.057                     
## ConditionC  -0.054  0.057  0.581              
## SssnPst:CnB  0.039 -0.079 -0.716 -0.416       
## SssnPst:CnC  0.038 -0.079 -0.413 -0.710  0.562
p1 <- ggplot(df_long_opioid_mean_away, aes(x=Session,y=RT, col = Condition)) +
  stat_summary(fun.data = "mean_cl_boot",position = position_dodge(width = .5))

p2 <- ggplot(df_long_opioid_mean_away, aes(x=Session,y=RT, col = Condition, group=Subject)) +
  geom_point(alpha = .03) + geom_line(alpha = .5)

cowplot::plot_grid(p1, p2, labels = c('Means', 'Individual Trajectories'), label_size = 12)

8c. Opioid Mean Toward

re_O_MT <- lmer(RT ~ (1|Subject), data = df_long_opioid_mean_toward)
performance::icc(re_O_MT)
## # Intraclass Correlation Coefficient
## 
##      Adjusted ICC: 0.752
##   Conditional ICC: 0.752
MLM_O_MT <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_opioid_mean_toward)
summary(MLM_O_MT)
## Linear mixed model fit by REML ['lmerMod']
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
##    Data: df_long_opioid_mean_toward
## 
## REML criterion at convergence: 92078.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.5379 -0.4689  0.0103  0.4140  5.6052 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  Subject  (Intercept) 2158.0   46.45         
##           SessionPost  475.8   21.81    -0.34
##  Residual              521.8   22.84         
## Number of obs: 10092, groups:  Subject, 27
## 
## Fixed effects:
##                        Estimate Std. Error t value
## (Intercept)            108.9211     8.9639  12.151
## SessionPost              5.1592     4.2968   1.201
## ConditionB              -0.6897     0.8587  -0.803
## ConditionC               8.9142     0.8560  10.414
## SessionPost:ConditionB  -4.2578     1.1989  -3.551
## SessionPost:ConditionC  -8.5259     1.2054  -7.073
## 
## Correlation of Fixed Effects:
##             (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.343                            
## ConditionB  -0.055  0.114                     
## ConditionC  -0.055  0.114  0.581              
## SssnPst:CnB  0.039 -0.158 -0.715 -0.416       
## SssnPst:CnC  0.039 -0.158 -0.412 -0.709  0.561
p1 <- ggplot(df_long_opioid_mean_toward, aes(x=Session,y=RT, col = Condition)) +
  stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .5))

p2 <- ggplot(df_long_opioid_mean_toward, aes(x=Session,y=RT, col = Condition, group=Subject)) +
  geom_point(alpha = .03) + geom_line(alpha = .5)

cowplot::plot_grid(p1, p2, labels = c('Means', 'Individual Trajectories'), label_size = 12)

## 8d. Opioid Peak Away

re_O_PA <- lmer(RT ~ (1|Subject), data = df_long_opioid_peak_away)
performance::icc(re_O_PA)
## # Intraclass Correlation Coefficient
## 
##      Adjusted ICC: 0.698
##   Conditional ICC: 0.698
MLM_O_PA <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_opioid_peak_away)
summary(MLM_O_PA)
## Linear mixed model fit by REML ['lmerMod']
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
##    Data: df_long_opioid_peak_away
## 
## REML criterion at convergence: 119135.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.8840 -0.4091 -0.0264  0.4088  3.1928 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  Subject  (Intercept) 22264    149.21        
##           SessionPost 12732    112.83   -0.10
##  Residual              7624     87.32        
## Number of obs: 10092, groups:  Subject, 27
## 
## Fixed effects:
##                        Estimate Std. Error t value
## (Intercept)             351.421     28.823  12.192
## SessionPost             -19.736     21.996  -0.897
## ConditionB              -19.984      3.283  -6.088
## ConditionC               16.974      3.272   5.187
## SessionPost:ConditionB   39.432      4.585   8.600
## SessionPost:ConditionC   29.091      4.610   6.310
## 
## Correlation of Fixed Effects:
##             (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.107                            
## ConditionB  -0.065  0.085                     
## ConditionC  -0.065  0.085  0.581              
## SssnPst:CnB  0.047 -0.118 -0.716 -0.416       
## SssnPst:CnC  0.046 -0.118 -0.412 -0.709  0.562
p1 <- ggplot(df_long_opioid_peak_away, aes(x=Session,y=RT, col = Condition)) +
  stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .5))

p2 <- ggplot(df_long_opioid_peak_away, aes(x=Session,y=RT, col = Condition, group=Subject)) +
  geom_point(alpha = .03) + geom_line(alpha = .5)

cowplot::plot_grid(p1, p2, labels = c('Means', 'Individual Trajectories'), label_size = 12)

8e. Peak Toward

re_O_PT <- lmer(RT ~ (1|Subject), data = df_long_opioid_peak_toward)
performance::icc(re_O_PA)
## # Intraclass Correlation Coefficient
## 
##      Adjusted ICC: 0.698
##   Conditional ICC: 0.698
MLM_O_PT <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_opioid_peak_toward)
summary(MLM_O_PA)
## Linear mixed model fit by REML ['lmerMod']
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
##    Data: df_long_opioid_peak_away
## 
## REML criterion at convergence: 119135.2
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.8840 -0.4091 -0.0264  0.4088  3.1928 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  Subject  (Intercept) 22264    149.21        
##           SessionPost 12732    112.83   -0.10
##  Residual              7624     87.32        
## Number of obs: 10092, groups:  Subject, 27
## 
## Fixed effects:
##                        Estimate Std. Error t value
## (Intercept)             351.421     28.823  12.192
## SessionPost             -19.736     21.996  -0.897
## ConditionB              -19.984      3.283  -6.088
## ConditionC               16.974      3.272   5.187
## SessionPost:ConditionB   39.432      4.585   8.600
## SessionPost:ConditionC   29.091      4.610   6.310
## 
## Correlation of Fixed Effects:
##             (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.107                            
## ConditionB  -0.065  0.085                     
## ConditionC  -0.065  0.085  0.581              
## SssnPst:CnB  0.047 -0.118 -0.716 -0.416       
## SssnPst:CnC  0.046 -0.118 -0.412 -0.709  0.562
p1 <- ggplot(df_long_opioid_peak_toward, aes(x=Session,y=RT, col = Condition)) +
  stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .5))

p2 <- ggplot(df_long_opioid_peak_toward, aes(x=Session,y=RT, col = Condition, group=Subject)) +
  geom_point(alpha = .03) + geom_line(alpha = .5)

cowplot::plot_grid(p1, p2, labels = c('Means', 'Individual Trajectories'), label_size = 12)

8f. Opioid Variability

re_O_V <- lmer(RT ~ (1|Subject), data = df_long_opioid_variability)
performance::icc(re_O_V)
## # Intraclass Correlation Coefficient
## 
##      Adjusted ICC: 0.831
##   Conditional ICC: 0.831
MLM_O_V <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_opioid_variability)
summary(MLM_O_V)
## Linear mixed model fit by REML ['lmerMod']
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
##    Data: df_long_opioid_variability
## 
## REML criterion at convergence: 83980.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.9644 -0.5350 -0.0231  0.5284  3.5415 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  Subject  (Intercept) 1466.7   38.30         
##           SessionPost  271.7   16.48    -0.03
##  Residual              233.3   15.28         
## Number of obs: 10092, groups:  Subject, 27
## 
## Fixed effects:
##                        Estimate Std. Error t value
## (Intercept)             94.4862     7.3833  12.797
## SessionPost              2.0716     3.2306   0.641
## ConditionB              -0.8049     0.5742  -1.402
## ConditionC               6.4867     0.5725  11.331
## SessionPost:ConditionB   0.1956     0.8019   0.244
## SessionPost:ConditionC   1.1036     0.8063   1.369
## 
## Correlation of Fixed Effects:
##             (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.032                            
## ConditionB  -0.045  0.102                     
## ConditionC  -0.045  0.102  0.581              
## SssnPst:CnB  0.032 -0.141 -0.715 -0.416       
## SssnPst:CnC  0.032 -0.140 -0.412 -0.709  0.562
p1 <- ggplot(df_long_opioid_variability, aes(x=Session,y=RT, col = Condition)) +
  stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .5))

p2 <- ggplot(df_long_opioid_variability, aes(x=Session,y=RT, col = Condition, group=Subject)) +
  geom_point(alpha = .03) + geom_line(alpha = .5)

cowplot::plot_grid(p1, p2, labels = c('Means', 'Individual Trajectories'), label_size = 12)

9. Pain Multilevel Models

9a. Pain Mean Bias

re_P_MB <- lmer(RT ~ (1|Subject), data = df_long_pain_mean_bias)
performance::icc(re_P_MB)
## # Intraclass Correlation Coefficient
## 
##      Adjusted ICC: 0.228
##   Conditional ICC: 0.228
MLM_P_MB <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_pain_mean_bias)
summary(MLM_P_MB)
## Linear mixed model fit by REML ['lmerMod']
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
##    Data: df_long_pain_mean_bias
## 
## REML criterion at convergence: 88054.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -4.3263 -0.4418 -0.0127  0.4833  3.9426 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  Subject  (Intercept) 252.7    15.90         
##           SessionPost 981.6    31.33    -0.62
##  Residual             358.5    18.93         
## Number of obs: 10068, groups:  Subject, 27
## 
## Fixed effects:
##                        Estimate Std. Error t value
## (Intercept)             -6.0782     3.1070  -1.956
## SessionPost              0.1933     6.0776   0.032
## ConditionB              -0.4129     0.7175  -0.575
## ConditionC               8.7778     0.7117  12.334
## SessionPost:ConditionB  11.2758     0.9982  11.296
## SessionPost:ConditionC  -0.5005     1.0016  -0.500
## 
## Correlation of Fixed Effects:
##             (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.621                            
## ConditionB  -0.132  0.068                     
## ConditionC  -0.133  0.068  0.584              
## SssnPst:CnB  0.095 -0.093 -0.719 -0.420       
## SssnPst:CnC  0.094 -0.093 -0.415 -0.711  0.564
p1 <- ggplot(df_long_pain_mean_bias, aes(x=Session,y=RT, col = Condition)) +
  stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .5))

p2 <- ggplot(df_long_pain_mean_bias, aes(x=Session,y=RT, col = Condition, group=Subject)) +
  geom_point(alpha = .03) + geom_line(alpha = .5)

cowplot::plot_grid(p1, p2, labels = c('Means', 'Individual Trajectories'), label_size = 12)

9b. Pain Mean Away

re_P_MA <- lmer(RT ~ (1|Subject), data = df_long_pain_mean_away)
performance::icc(re_P_MA)
## # Intraclass Correlation Coefficient
## 
##      Adjusted ICC: 0.799
##   Conditional ICC: 0.799
MLM_P_MA <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_pain_mean_away)
summary(MLM_P_MA)
## Linear mixed model fit by REML ['lmerMod']
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
##    Data: df_long_pain_mean_away
## 
## REML criterion at convergence: 92114.7
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.2644 -0.5836 -0.0168  0.3945  3.4382 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr
##  Subject  (Intercept) 2741.0   52.35        
##           SessionPost 1108.0   33.29    0.10
##  Residual              533.6   23.10        
## Number of obs: 10068, groups:  Subject, 27
## 
## Fixed effects:
##                        Estimate Std. Error t value
## (Intercept)            117.4826    10.0974  11.635
## SessionPost              6.8379     6.4732   1.056
## ConditionB             -11.4028     0.8759 -13.019
## ConditionC              -2.5862     0.8687  -2.977
## SessionPost:ConditionB   0.7987     1.2179   0.656
## SessionPost:ConditionC  -2.1198     1.2219  -1.735
## 
## Correlation of Fixed Effects:
##             (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost  0.096                            
## ConditionB  -0.050  0.077                     
## ConditionC  -0.050  0.078  0.585              
## SssnPst:CnB  0.036 -0.107 -0.719 -0.420       
## SssnPst:CnC  0.035 -0.106 -0.415 -0.711  0.564
p1 <- ggplot(df_long_pain_mean_away, aes(x=Session,y=RT, col = Condition)) +
  stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .5))

p2 <- ggplot(df_long_pain_mean_away, aes(x=Session,y=RT, col = Condition, group=Subject)) +
  geom_point(alpha = .03) + geom_line(alpha = .5)

cowplot::plot_grid(p1, p2, labels = c('Means', 'Individual Trajectories'), label_size = 12)

9c. Pain Mean Toward

re_P_MT <- lmer(RT ~ (1|Subject), data = df_long_pain_mean_toward)
performance::icc(re_P_MT)
## # Intraclass Correlation Coefficient
## 
##      Adjusted ICC: 0.776
##   Conditional ICC: 0.776
MLM_P_MT <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_pain_mean_toward)
summary(MLM_P_MT)
## Linear mixed model fit by REML ['lmerMod']
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
##    Data: df_long_pain_mean_toward
## 
## REML criterion at convergence: 88946.4
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.8602 -0.6315  0.0084  0.5074  3.2242 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr
##  Subject  (Intercept) 1873.7   43.29        
##           SessionPost  866.5   29.44    0.21
##  Residual              389.5   19.74        
## Number of obs: 10068, groups:  Subject, 27
## 
## Fixed effects:
##                        Estimate Std. Error t value
## (Intercept)            109.5008     8.3496  13.115
## SessionPost             -0.4059     5.7205  -0.071
## ConditionB              -5.9517     0.7483  -7.954
## ConditionC               6.5023     0.7422   8.761
## SessionPost:ConditionB  17.8700     1.0405  17.175
## SessionPost:ConditionC   6.7531     1.0439   6.469
## 
## Correlation of Fixed Effects:
##             (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost  0.202                            
## ConditionB  -0.051  0.075                     
## ConditionC  -0.051  0.075  0.585              
## SssnPst:CnB  0.037 -0.103 -0.719 -0.420       
## SssnPst:CnC  0.037 -0.103 -0.415 -0.710  0.564
p1 <- ggplot(df_long_pain_mean_toward, aes(x=Session,y=RT, col = Condition)) +
  stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .5))

p2 <- ggplot(df_long_pain_mean_toward, aes(x=Session,y=RT, col = Condition, group=Subject)) +
  geom_point(alpha = .03) + geom_line(alpha = .5)

cowplot::plot_grid(p1, p2, labels = c('Means', 'Individual Trajectories'), label_size = 12)

9d. Pain Peak Away

re_P_PA <- lmer(RT ~ (1|Subject), data = df_long_pain_peak_away)
performance::icc(re_P_PA)
## # Intraclass Correlation Coefficient
## 
##      Adjusted ICC: 0.772
##   Conditional ICC: 0.772
MLM_P_PA <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_pain_peak_away)
summary(MLM_P_PA)
## Linear mixed model fit by REML ['lmerMod']
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
##    Data: df_long_pain_peak_away
## 
## REML criterion at convergence: 114268
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.6602 -0.5716 -0.0351  0.5313  2.6174 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr 
##  Subject  (Intercept) 24237    155.68        
##           SessionPost 10295    101.47   -0.09
##  Residual              4824     69.46        
## Number of obs: 10068, groups:  Subject, 27
## 
## Fixed effects:
##                        Estimate Std. Error t value
## (Intercept)             351.736     30.027  11.714
## SessionPost              34.343     19.726   1.741
## ConditionB               -5.647      2.634  -2.144
## ConditionC               12.197      2.612   4.669
## SessionPost:ConditionB  -16.145      3.662  -4.409
## SessionPost:ConditionC  -40.675      3.674 -11.070
## 
## Correlation of Fixed Effects:
##             (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.096                            
## ConditionB  -0.050  0.076                     
## ConditionC  -0.050  0.077  0.585              
## SssnPst:CnB  0.036 -0.105 -0.719 -0.420       
## SssnPst:CnC  0.036 -0.105 -0.415 -0.711  0.564
p1 <- ggplot(df_long_pain_peak_away, aes(x=Session,y=RT, col = Condition)) +
  stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .5))

p2 <- ggplot(df_long_pain_peak_away, aes(x=Session,y=RT, col = Condition, group=Subject)) +
  geom_point(alpha = .03) + geom_line(alpha = .5)

cowplot::plot_grid(p1, p2, labels = c('Means', 'Individual Trajectories'), label_size = 12)

## 9e. Pain Peak Toward

re_P_PT <- lmer(RT ~ (1|Subject), data = df_long_pain_peak_toward)
performance::icc(re_P_PT)
## # Intraclass Correlation Coefficient
## 
##      Adjusted ICC: 0.761
##   Conditional ICC: 0.761
MLM_P_PT <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_pain_peak_toward)
summary(MLM_P_PT)
## Linear mixed model fit by REML ['lmerMod']
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
##    Data: df_long_pain_peak_toward
## 
## REML criterion at convergence: 112853.5
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -3.7776 -0.5155 -0.0104  0.5215  2.3744 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr
##  Subject  (Intercept) 17732    133.16       
##           SessionPost  9003     94.88   0.11
##  Residual              4193     64.76       
## Number of obs: 10068, groups:  Subject, 27
## 
## Fixed effects:
##                        Estimate Std. Error t value
## (Intercept)            335.1592    25.6945  13.044
## SessionPost             18.8009    18.4454   1.019
## ConditionB              -0.3478     2.4552  -0.142
## ConditionC              36.4570     2.4351  14.972
## SessionPost:ConditionB  16.7017     3.4140   4.892
## SessionPost:ConditionC -23.2612     3.4253  -6.791
## 
## Correlation of Fixed Effects:
##             (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost  0.097                            
## ConditionB  -0.055  0.076                     
## ConditionC  -0.055  0.076  0.585              
## SssnPst:CnB  0.039 -0.105 -0.719 -0.420       
## SssnPst:CnC  0.039 -0.105 -0.415 -0.711  0.564
p1 <- ggplot(df_long_pain_peak_toward, aes(x=Session,y=RT, col = Condition)) +
  stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .5))

p2 <- ggplot(df_long_pain_peak_toward, aes(x=Session,y=RT, col = Condition, group=Subject)) +
  geom_point(alpha = .03) + geom_line(alpha = .5)

cowplot::plot_grid(p1, p2, labels = c('Means', 'Individual Trajectories'), label_size = 12)

9f. Variability

re_P_V <- lmer(RT ~ (1|Subject), data = df_long_pain_variability)
performance::icc(re_P_V)
## # Intraclass Correlation Coefficient
## 
##      Adjusted ICC: 0.847
##   Conditional ICC: 0.847
MLM_P_V <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_pain_variability)
summary(MLM_P_V)
## Linear mixed model fit by REML ['lmerMod']
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
##    Data: df_long_pain_variability
## 
## REML criterion at convergence: 82455.9
## 
## Scaled residuals: 
##     Min      1Q  Median      3Q     Max 
## -2.2579 -0.5738 -0.0184  0.3713  3.4522 
## 
## Random effects:
##  Groups   Name        Variance Std.Dev. Corr
##  Subject  (Intercept) 1660.6   40.75        
##           SessionPost  554.3   23.54    0.04
##  Residual              204.0   14.28        
## Number of obs: 10068, groups:  Subject, 27
## 
## Fixed effects:
##                        Estimate Std. Error t value
## (Intercept)             94.6197     7.8532  12.049
## SessionPost              5.5569     4.5674   1.217
## ConditionB              -1.1481     0.5416  -2.120
## ConditionC               5.2820     0.5371   9.834
## SessionPost:ConditionB   1.7182     0.7531   2.282
## SessionPost:ConditionC  -1.1471     0.7556  -1.518
## 
## Correlation of Fixed Effects:
##             (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost  0.033                            
## ConditionB  -0.039  0.068                     
## ConditionC  -0.040  0.068  0.585              
## SssnPst:CnB  0.028 -0.094 -0.719 -0.420       
## SssnPst:CnC  0.028 -0.093 -0.415 -0.711  0.564
p1 <- ggplot(df_long_pain_variability, aes(x=Session,y=RT, col = Condition)) +
  stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .5))

p2 <- ggplot(df_long_pain_variability, aes(x=Session,y=RT, col = Condition, group=Subject)) +
  geom_point(alpha = .03) + geom_line(alpha = .5)

cowplot::plot_grid(p1, p2, labels = c('Means', 'Individual Trajectories'), label_size = 12)