<style type="text/css">
div.main-container {
max-width: 100%;
margin-left: auto;
margin-right: auto;
}
</style>
-Note: Large chunks of code have been hidden to improve readibility. -NOTE: Did some reading, this data is a particular type of MLM: “Cross-classified”. This means our level 1 units (i.e., RT observations) are clustered within two grouping variables (1 = Subject, 2 = Condition). Need to do a little more research on this. ## 1. Load Packages Used in Data Analysis -Code hidden
-Code hidden
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
-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 Per_SD…¹
## <fct> <int> <dbl> <dbl> <dbl> <dbl>
## 1 1 4005 205 0.0512 79 0.0197
## 2 2 3931 138 0.0351 54 0.0137
## 3 3 3551 115 0.0324 47 0.0132
## 4 4 3538 119 0.0336 50 0.0141
## 5 5 2746 114 0.0415 54 0.0197
## 6 6 2725 128 0.0470 52 0.0191
## # … with abbreviated variable name ¹Per_SD3_Over
-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
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 Condi…¹ Session Cue Mean_…² Mean_…³ Mean_…⁴ Peak_…⁵ Peak_…⁶ Varia…⁷
## <dbl> <chr> <fct> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 56001 C 1 opio… 6.24 97.9 103. 442 203 82.1
## 2 56001 C 1 pain 33.2 139. 61.2 429 226 76.5
## 3 56001 C 2 opio… 12.3 114. 110. 402 296 87.9
## 4 56001 C 2 pain 0.776 100. 107. 380 287 76.7
## 5 56001 A 3 opio… 22.9 115. 113. 350 528 101.
## 6 56001 A 3 pain 4.97 65.3 89.6 228 228 74.2
## 7 56001 A 4 opio… -39.8 82.1 106. 240 347 73.7
## 8 56001 A 4 pain 1.86 75.7 101. 326 486 80.2
## 9 56001 B 5 opio… -0.504 88.8 65.7 251 178 64.5
## 10 56001 B 5 pain 9.94 110. 52.1 305 289 79.9
## # … with 258 more rows, and abbreviated variable names ¹Condition, ²Mean_Bias,
## # ³Mean_Toward, ⁴Mean_Away, ⁵Peak_Toward, ⁶Peak_Away, ⁷Variability
By_Condition_Output
## # A tibble: 36 × 9
## # Groups: Condition, Session [18]
## Condition Session Cue Mean_Bias Mean_Tow…¹ Mean_…² Peak_…³ Peak_…⁴ Varia…⁵
## <chr> <fct> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 A 1 opioid -4.88 112. 117. 323. 317. 92.8
## 2 A 1 pain 1.90 117. 125. 400. 353. 98.4
## 3 B 1 opioid -3.52 95.1 90.3 318. 313. 89.7
## 4 B 1 pain 6.39 84.6 90.5 292. 290. 81.8
## 5 C 1 opioid -9.58 119. 128. 364. 367. 104.
## 6 C 1 pain 5.10 130. 118. 396. 386. 107.
## 7 A 2 opioid 20.0 102. 96.6 317. 329. 89.9
## 8 A 2 pain -10.2 93.9 105. 354. 341. 89.9
## 9 B 2 opioid 3.00 106. 109. 406. 331. 86.2
## 10 B 2 pain 28.8 117. 96.1 364. 299. 94.3
## # … with 26 more rows, and abbreviated variable names ¹Mean_Toward, ²Mean_Away,
## # ³Peak_Toward, ⁴Peak_Away, ⁵Variability
By_Session_Output
## # A tibble: 12 × 8
## # Groups: Session [6]
## Session Cue Mean_Bias Mean_Toward Mean_Away Peak_Toward Peak_Away Variab…¹
## <fct> <fct> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
## 1 1 opioid -6.27 109. 113. 337. 335. 96.2
## 2 1 pain 4.50 113. 112. 366. 347. 96.9
## 3 2 opioid 1.82 108. 110. 357. 341. 93.2
## 4 2 pain 6.25 110. 112. 359. 342. 96.2
## 5 3 opioid -0.233 111. 108. 373. 364. 94.1
## 6 3 pain -4.52 105. 111. 338. 353. 94.5
## 7 4 opioid 4.76 111. 110. 377. 352. 93.3
## 8 4 pain 2.01 110. 106. 343. 362. 96.2
## 9 5 opioid -3.19 106. 105. 324. 348. 92.1
## 10 5 pain -13.3 103. 107. 326. 342. 90.4
## 11 6 opioid -3.74 105. 110. 335. 329. 96.1
## 12 6 pain -12.3 106. 116. 313. 348. 91.9
## # … with abbreviated variable name ¹Variability
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
-Code Hidden -Changing session variable to represent just pre-post
-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") %>%
mutate(Subject = factor(Subject)) %>%
distinct()
dim(df_long) #Dataframe dimensions
## [1] 1608 6
# Number of RT's each participant contributes to the dataframe
table(df_long$Subject)
##
## 56001 56002 56003 56004 56005 56006 56007 56008 56009 56010 56011 56012 56013
## 72 60 36 72 72 72 72 72 72 72 48 72 24
## 56014 56015 56016 56017 56018 56019 56020 56021 56022 56023 56025 56026 56027
## 36 60 72 24 24 72 72 72 48 48 72 72 72
## 56028
## 48
data.frame(table(df_long$Subject)) %>% summarise(Min = min(Freq), Max = max(Freq))
## Min Max
## 1 24 72
-DV: Opioid Mean Bias
-DV: Pain Mean Bias
-DV: Opioid Mean Away Bias
-DV: Pain Mean Away Bias
-DV: Opioid Mean Toward Bias
-DV: Pain Mean Toward Bias
-DV: Opioid Peak Away Bias
-DV: Pain Peak Away Bias
-DV: Opioid Peak Toward Bias
-DV: Pain Peak Toward Bias
-DV: Opioid Variability Bias
-DV: Pain Variability Bias
-DV: Opioid Mean Bias
re_O_MB1 <- lmer(RT ~ (1|Subject), data = df_long_opioid_mean_bias)
re_O_MB2 <- lmer(RT ~ (1|Condition), data = df_long_opioid_mean_bias)
performance::icc(re_O_MB1)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.088
## Conditional ICC: 0.088
performance::icc(re_O_MB2)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.002
## Conditional ICC: 0.002
MLM_O_MB <- lmer(RT ~ Session*Condition + (1 + Session|Subject), data = df_long_opioid_mean_bias)
#The code below then obtains mltiple Degree-of-Freedom F-Tests for the above-specified model
anova(MLM_O_MB, type = "III")
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## Session 204.29 204.29 1 25.962 0.3180 0.5777
## Condition 1456.11 728.06 2 84.311 1.1332 0.3268
## Session:Condition 1513.27 756.63 2 83.174 1.1777 0.3131
#Model Parameters
summary(MLM_O_MB)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
## Data: df_long_opioid_mean_bias
##
## REML criterion at convergence: 1244.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.21980 -0.47485 -0.01903 0.39442 3.14079
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## Subject (Intercept) 348.7 18.67
## SessionPost 613.7 24.77 -0.85
## Residual 642.5 25.35
## Number of obs: 134, groups: Subject, 27
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) -3.3981 7.0389 74.7171 -0.483 0.631
## SessionPost 8.6312 9.6716 75.8654 0.892 0.375
## ConditionB 9.1184 8.0190 85.2335 1.137 0.259
## ConditionC -5.5859 8.0191 85.2271 -0.697 0.488
## SessionPost:ConditionB -14.4242 11.1918 83.9354 -1.289 0.201
## SessionPost:ConditionC -0.3397 11.2622 84.4068 -0.030 0.976
##
## Correlation of Fixed Effects:
## (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.754
## ConditionB -0.649 0.475
## ConditionC -0.649 0.475 0.573
## SssnPst:CnB 0.467 -0.650 -0.719 -0.413
## SssnPst:CnC 0.464 -0.647 -0.410 -0.715 0.559
#Means/SDs
df_long_opioid_mean_bias %>% select(-Cue, -Bias_Type) %>% group_by(Session, Condition) %>% summarise(M = mean(RT), SD = sd(RT))
## `summarise()` has grouped output by 'Session'. You can override using the
## `.groups` argument.
## # A tibble: 6 × 4
## # Groups: Session [2]
## Session Condition M SD
## <fct> <chr> <dbl> <dbl>
## 1 Pre A -4.26 31.4
## 2 Pre B 4.98 26.2
## 3 Pre C -10.7 33.1
## 4 Post A 5.55 34.4
## 5 Post B 0.433 23.7
## 6 Post C -0.937 31.5
emmeans::emmeans(MLM_O_MB, specs = c("Session", "Condition"))
## Session Condition emmean SE df lower.CL upper.CL
## Pre A -3.3981 7.08 75.2 -17.50 10.71
## Post A 5.2331 6.40 80.5 -7.51 17.97
## Pre B 5.7204 6.39 64.4 -7.04 18.48
## Post B -0.0727 5.85 74.5 -11.73 11.59
## Pre C -8.9840 6.39 64.4 -21.75 3.78
## Post C -0.6925 5.98 76.0 -12.59 11.21
##
## Degrees-of-freedom method: kenward-roger
## Confidence level used: 0.95
#Actual Means
AM <- ggplot(df_long_opioid_mean_bias, aes(x=Session,y=RT, col = Condition)) +
stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = 0.5)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Means
PM <- ggplot(df_long_opioid_mean_bias, aes(x=Session,y=predict(MLM_O_MB), col = Condition)) +
stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = 0.5)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Actual Trajectories
AT <- ggplot(df_long_opioid_mean_bias, aes(x=Session,y=RT, col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Trajectories
PT <- ggplot(df_long_opioid_mean_bias, aes(x=Session,y=predict(MLM_O_MB), col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
cowplot::plot_grid(AM,PM)
cowplot::plot_grid(AT,PT)
-DV: Pain Mean Bias
re_P_MB <- lmer(RT ~ (1|Subject), data = df_long_pain_mean_bias)
## boundary (singular) fit: see help('isSingular')
performance::icc(re_P_MB) #Error suggesting singularity
## Warning: Can't compute random effect variances. Some variance components equal
## zero. Your model may suffer from singularity (see '?lme4::isSingular'
## and '?performance::check_singularity').
## Solution: Respecify random structure! You may also decrease the
## 'tolerance' level to enforce the calculation of random effect variances.
## [1] NA
MLM_P_MB <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_pain_mean_bias,
control = lmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e5)))
## boundary (singular) fit: see help('isSingular')
#^Control liner above added to assist with convergence after receiving the following error:
#Warning: Model failed to converge with 1 negative eigenvalue: -1.1e+01
#Afterwards, the error "boundary (singular) fit: see help('isSingular')" suggests our random effects here are very small or close to 0
isSingular(MLM_P_MB) #Verifies at least 1 random effect is small or close to 0
## [1] TRUE
sort(ranef(MLM_P_MB)$Subject$SessionPost)
## [1] -42.3063695 -17.0144423 -14.5056858 -8.0426982 -7.9748766 -7.5214568
## [7] -6.8313886 -6.3681574 -5.2028858 -3.3422080 -2.1602777 -1.4978784
## [13] 0.9296805 1.5842522 2.1819631 2.5023526 3.1776712 4.0387206
## [19] 5.6043898 5.7400824 6.6377156 7.1038794 10.8902859 11.5768786
## [25] 13.8137212 15.2284504 31.7582818
sort(ranef(MLM_P_MB)$Subject$`(Intercept)`)
## [1] -9.5217201 -4.5657710 -4.1416090 -3.4709622 -3.2651091 -2.1298744
## [7] -1.9901099 -1.7209828 -1.6802997 -1.2108831 -0.9527246 -0.7502516
## [13] -0.6541929 -0.4749881 -0.2787354 0.4490916 0.6476912 1.0020558
## [19] 1.5599214 1.9092913 2.0481766 2.2550718 2.3910155 2.4113496
## [25] 4.3490728 5.1012444 12.6842318
#Multiple Degree-of-Freedome F-Tests
anova(MLM_P_MB, type = "III")
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## Session 205.71 205.71 1 22.746 0.3232 0.5753
## Condition 925.42 462.71 2 100.496 0.7270 0.4859
## Session:Condition 993.78 496.89 2 106.258 0.7807 0.4607
#Means/SDs
df_long_pain_mean_bias %>% select(-Cue, -Bias_Type) %>% group_by(Session, Condition) %>% summarise(M = mean(RT), SD = sd(RT)) %>% arrange(Condition, Session)
## `summarise()` has grouped output by 'Session'. You can override using the
## `.groups` argument.
## # A tibble: 6 × 4
## # Groups: Session [2]
## Session Condition M SD
## <fct> <chr> <dbl> <dbl>
## 1 Pre A -4.69 22.8
## 2 Post A -7.40 36.3
## 3 Pre B -6.71 20.8
## 4 Post B 3.85 32.3
## 5 Pre C 0.104 26.5
## 6 Post C 1.59 21.6
emmeans::emmeans(MLM_P_MB, specs = c("Session", "Condition"), lmer.df = "asymp")
## Session Condition emmean SE df asymp.LCL asymp.UCL
## Pre A -5.005 5.93 Inf -16.62 6.61
## Post A -6.640 6.36 Inf -19.10 5.82
## Pre B -6.984 5.28 Inf -17.34 3.37
## Post B 3.966 5.84 Inf -7.48 15.42
## Pre C 0.391 5.28 Inf -9.96 10.75
## Post C 1.066 5.96 Inf -10.61 12.74
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
#Parameter Estimates
summary(MLM_P_MB)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
## Data: df_long_pain_mean_bias
## Control: lmerControl(optimizer = "bobyqa", optCtrl = list(maxfun = 2e+05))
##
## REML criterion at convergence: 1224.1
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -3.4227 -0.4652 0.0981 0.4275 3.4955
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## Subject (Intercept) 34.55 5.878
## SessionPost 384.34 19.605 -1.00
## Residual 636.45 25.228
## Number of obs: 134, groups: Subject, 27
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) -5.005 5.926 91.776 -0.845 0.401
## SessionPost -1.634 9.103 83.223 -0.180 0.858
## ConditionB -1.979 7.775 99.414 -0.255 0.800
## ConditionC 5.396 7.776 99.474 0.694 0.489
## SessionPost:ConditionB 12.585 11.035 106.703 1.140 0.257
## SessionPost:ConditionC 2.309 11.114 108.016 0.208 0.836
##
## Correlation of Fixed Effects:
## (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.719
## ConditionB -0.734 0.487
## ConditionC -0.734 0.487 0.560
## SssnPst:CnB 0.526 -0.678 -0.713 -0.402
## SssnPst:CnC 0.523 -0.675 -0.399 -0.709 0.555
## optimizer (bobyqa) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
#Actual Means
AM <- 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)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Means
PM <- ggplot(df_long_pain_mean_bias, aes(x=Session,y=predict(MLM_P_MB), col = Condition)) +
stat_summary(fun.data = "mean_cl_boot", position = position_dodge(width = .5)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Actual Trajectories
AT <- ggplot(df_long_pain_mean_bias, aes(x=Session,y=RT, col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Trajectories
PT <- ggplot(df_long_pain_mean_bias, aes(x=Session,y=predict(MLM_P_MB), col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
cowplot::plot_grid(AM, PM)
cowplot::plot_grid(AT, PT)
-DV: Opioid Mean Away Bias
re_O_MA <- lmer(RT ~ (1|Subject), data = df_long_opioid_mean_away)
performance::icc(re_O_MA)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.635
## Conditional ICC: 0.635
MLM_O_MA <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_opioid_mean_away)
#Multiple Degree-of-Freedome F-Tests
anova(MLM_O_MA, type = "III")
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## Session 378.16 378.16 1 19.678 0.4061 0.5313
## Condition 2073.29 1036.65 2 73.367 1.1133 0.3340
## Session:Condition 1003.54 501.77 2 78.812 0.5389 0.5855
#Means/SDs
df_long_opioid_mean_away %>% select(-Cue, -Bias_Type) %>% group_by(Session, Condition) %>% summarise(M = mean(RT), SD = sd(RT)) %>% arrange(Condition, Session)
## `summarise()` has grouped output by 'Session'. You can override using the
## `.groups` argument.
## # A tibble: 6 × 4
## # Groups: Session [2]
## Session Condition M SD
## <fct> <chr> <dbl> <dbl>
## 1 Pre A 106. 57.7
## 2 Post A 104. 63.5
## 3 Pre B 109. 41.6
## 4 Post B 115. 57.5
## 5 Pre C 114. 53.9
## 6 Post C 115. 54.2
emmeans::emmeans(MLM_O_MA, specs = c("Session", "Condition"), lmer.df = "asymp")
## Session Condition emmean SE df asymp.LCL asymp.UCL
## Pre A 114 10.7 Inf 92.7 135
## Post A 111 12.2 Inf 86.8 135
## Pre B 105 10.1 Inf 84.8 124
## Post B 116 11.8 Inf 92.5 139
## Pre C 117 10.1 Inf 96.8 136
## Post C 122 11.9 Inf 98.8 145
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
#Parameter Estimates
summary(MLM_O_MA)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
## Data: df_long_opioid_mean_away
##
## REML criterion at convergence: 1331.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.35516 -0.51551 -0.03073 0.32946 2.74247
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## Subject (Intercept) 1662.8 40.78
## SessionPost 560.4 23.67 0.21
## Residual 931.1 30.51
## Number of obs: 134, groups: Subject, 27
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 113.691 10.727 52.602 10.599 1.16e-14 ***
## SessionPost -2.904 11.013 76.200 -0.264 0.793
## ConditionB -9.120 9.685 78.400 -0.942 0.349
## ConditionC 2.920 9.688 78.215 0.301 0.764
## SessionPost:ConditionB 13.874 13.386 80.066 1.036 0.303
## SessionPost:ConditionC 8.388 13.462 80.923 0.623 0.535
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.368
## ConditionB -0.515 0.479
## ConditionC -0.515 0.479 0.574
## SssnPst:CnB 0.358 -0.678 -0.702 -0.398
## SssnPst:CnC 0.356 -0.675 -0.395 -0.695 0.553
#Actual Means
AM <- 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)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Means
PM <- ggplot(df_long_opioid_mean_away, aes(x=Session,y=predict(MLM_O_MA), col = Condition)) +
stat_summary(fun.data = "mean_cl_boot",position = position_dodge(width = .5)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Actual Trajectories
AT <- ggplot(df_long_opioid_mean_away, aes(x=Session,y=RT, col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Trajectories
PT <- ggplot(df_long_opioid_mean_away, aes(x=Session,y=predict(MLM_O_MA), col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
cowplot::plot_grid(AM, PM)
cowplot::plot_grid(AT, PT)
-DV: Pain Mean Away Bias
re_P_MA <- lmer(RT ~ (1|Subject), data = df_long_pain_mean_away)
performance::icc(re_P_MA)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.745
## Conditional ICC: 0.745
MLM_P_MA <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_pain_mean_away)
## boundary (singular) fit: see help('isSingular')
isSingular(MLM_P_MA)
## [1] TRUE
sort(ranef(MLM_P_MA)$Subject$`(Intercept)`)
## [1] -61.776219 -54.665690 -52.059154 -51.677697 -37.635016 -34.312018
## [7] -33.254421 -30.227359 -29.795603 -27.511059 -26.495697 -25.802310
## [13] -19.444777 -16.179419 -14.981120 -11.998298 5.576683 14.518520
## [19] 15.879711 20.948924 37.164520 38.355486 63.294253 65.290005
## [25] 67.449688 89.235722 110.102345
sort(ranef(MLM_P_MA)$Subject$Session)
## [1] -14.077398 -12.457070 -11.863099 -11.776174 -8.576166 -7.818930
## [7] -7.577928 -6.888129 -6.789741 -6.269146 -6.037768 -5.879761
## [13] -4.431023 -3.686922 -3.413857 -2.734140 1.270799 3.308441
## [19] 3.618626 4.773784 8.468950 8.740344 14.423323 14.878110
## [25] 15.370252 20.334795 25.089825
#Multiple Degree-of-Freedome F-Tests
anova(MLM_P_MA, type = "III")
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## Session 1036.10 1036.10 1 53.137 1.1259 0.2935
## Condition 2778.59 1389.30 2 103.619 1.5097 0.2258
## Session:Condition 8.41 4.21 2 101.765 0.0046 0.9954
#Means/SDs
df_long_pain_mean_away %>% select(-Cue, -Bias_Type) %>% group_by(Session, Condition) %>% summarise(M = mean(RT), SD = sd(RT)) %>% arrange(Condition, Session)
## `summarise()` has grouped output by 'Session'. You can override using the
## `.groups` argument.
## # A tibble: 6 × 4
## # Groups: Session [2]
## Session Condition M SD
## <fct> <chr> <dbl> <dbl>
## 1 Pre A 110. 60.3
## 2 Post A 114. 69.2
## 3 Pre B 112. 47.9
## 4 Post B 111. 48.7
## 5 Pre C 112. 62.3
## 6 Post C 115. 70.9
emmeans::emmeans(MLM_P_MA, specs = c("Session", "Condition"), lmer.df = "asymp")
## Session Condition emmean SE df asymp.LCL asymp.UCL
## Pre A 118 11.8 Inf 94.4 141
## Post A 123 13.5 Inf 96.6 150
## Pre B 107 11.3 Inf 84.6 129
## Post B 113 13.1 Inf 86.8 138
## Pre C 115 11.3 Inf 93.1 137
## Post C 122 13.2 Inf 96.0 148
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
#Parameter Estimates
summary(MLM_P_MA)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
## Data: df_long_pain_mean_away
##
## REML criterion at convergence: 1327.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.6290 -0.4581 -0.1128 0.3960 2.9067
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## Subject (Intercept) 2370.6 48.69
## SessionPost 123.1 11.10 1.00
## Residual 920.3 30.34
## Number of obs: 134, groups: Subject, 27
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 117.5566 11.8121 45.3740 9.952 5.51e-13 ***
## SessionPost 5.5747 9.9752 99.1065 0.559 0.578
## ConditionB -10.8324 9.5488 102.4076 -1.134 0.259
## ConditionC -2.3703 9.5563 102.4536 -0.248 0.805
## SessionPost:ConditionB 0.2646 13.1255 101.7211 0.020 0.984
## SessionPost:ConditionC 1.1766 13.1818 101.7196 0.089 0.929
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.239
## ConditionB -0.458 0.506
## ConditionC -0.458 0.506 0.570
## SssnPst:CnB 0.314 -0.724 -0.696 -0.389
## SssnPst:CnC 0.312 -0.721 -0.387 -0.689 0.547
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
#Actual Means
AM <- 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)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Means
PM <- ggplot(df_long_pain_mean_away, aes(x=Session,y=predict(MLM_P_MA), col = Condition)) +
stat_summary(fun.data = "mean_cl_boot",position = position_dodge(width = .5)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Actual Trajectories
AT <- ggplot(df_long_pain_mean_away, aes(x=Session,y=RT, col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Trajectories
PT <- ggplot(df_long_pain_mean_away, aes(x=Session,y=predict(MLM_P_MA), col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
cowplot::plot_grid(AM,PM)
cowplot::plot_grid(AT,PT)
-DV: Opioid Mean Toward Bias
re_O_MT <- lmer(RT ~ (1|Subject), data = df_long_opioid_mean_toward)
performance::icc(re_O_MT)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.684
## Conditional ICC: 0.684
MLM_O_MT <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_opioid_mean_toward)
## boundary (singular) fit: see help('isSingular')
sort(ranef(MLM_O_MT)$Subject$`(Intercept)`)
## [1] -61.455301 -60.399322 -48.041706 -46.921089 -43.170230 -36.541374
## [7] -34.106747 -33.248814 -23.532836 -22.155296 -21.363462 -13.232440
## [13] -11.055716 -7.817941 -3.257319 7.606120 11.125959 11.856406
## [19] 13.961734 30.798315 40.779379 44.787095 44.913828 58.980504
## [25] 64.786503 65.348250 71.355499
sort(ranef(MLM_O_MT)$Subject$Session)
## [1] -2.5383099 -2.3246156 -2.3046327 -2.0980975 -1.5977074 -1.5931992
## [7] -1.4506338 -1.0955801 -0.4966570 -0.4217647 -0.3957807 -0.2705704
## [13] 0.1158717 0.2781055 0.3932820 0.4707140 0.7599566 0.7881243
## [19] 0.8371272 1.1827510 1.2132701 1.2998764 1.5356829 1.6691112
## [25] 1.7089746 2.1485687 2.1861328
#Multiple Degree-of-Freedome F-Tests
anova(MLM_O_MT, type = "III")
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## Session 46.89 46.89 1 100.02 0.0567 0.8123
## Condition 1626.97 813.48 2 104.62 0.9838 0.3773
## Session:Condition 459.86 229.93 2 102.02 0.2781 0.7578
#Means/SDs
df_long_opioid_mean_toward %>% select(-Cue, -Bias_Type) %>% group_by(Session, Condition) %>% summarise(M = mean(RT), SD = sd(RT)) %>% arrange(Condition, Session)
## `summarise()` has grouped output by 'Session'. You can override using the
## `.groups` argument.
## # A tibble: 6 × 4
## # Groups: Session [2]
## Session Condition M SD
## <fct> <chr> <dbl> <dbl>
## 1 Pre A 101. 52.4
## 2 Post A 111. 51.6
## 3 Pre B 113. 40.0
## 4 Post B 107. 37.8
## 5 Pre C 115. 63.1
## 6 Post C 110. 52.9
emmeans::emmeans(MLM_O_MT, specs = c("Session", "Condition"), lmer.df = "asymp")
## Session Condition emmean SE df asymp.LCL asymp.UCL
## Pre A 108 10.75 Inf 87.3 129
## Post A 115 10.39 Inf 94.6 135
## Pre B 109 10.21 Inf 89.0 129
## Post B 108 9.97 Inf 88.7 128
## Pre C 118 10.21 Inf 98.1 138
## Post C 116 10.06 Inf 96.2 136
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
#Parameter Estimates
summary(MLM_O_MT)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
## Data: df_long_opioid_mean_toward
##
## REML criterion at convergence: 1304.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.4295 -0.4645 -0.0749 0.3621 4.2082
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## Subject (Intercept) 1849.12 43.00
## SessionPost 2.34 1.53 -1.00
## Residual 826.85 28.75
## Number of obs: 134, groups: Subject, 27
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 108.3702 10.7536 47.9798 10.078 1.97e-13 ***
## SessionPost 6.5845 9.2397 101.8382 0.713 0.478
## ConditionB 0.6354 9.1018 103.5472 0.070 0.944
## ConditionC 9.7676 9.1089 103.6244 1.072 0.286
## SessionPost:ConditionB -7.3799 12.4482 102.0260 -0.593 0.555
## SessionPost:ConditionC -8.7908 12.4953 101.9863 -0.704 0.483
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.468
## ConditionB -0.481 0.525
## ConditionC -0.481 0.524 0.573
## SssnPst:CnB 0.333 -0.742 -0.701 -0.394
## SssnPst:CnC 0.331 -0.739 -0.392 -0.694 0.549
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
#Actual Means
AM <- 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)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Means
PM <- ggplot(df_long_opioid_mean_toward, aes(x=Session,y=predict(MLM_O_MT), col = Condition)) +
stat_summary(fun.data = "mean_cl_boot",position = position_dodge(width = .5)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Actual Trajectories
AT <- ggplot(df_long_opioid_mean_toward, aes(x=Session,y=RT, col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Trajectories
PT <- ggplot(df_long_opioid_mean_toward, aes(x=Session,y=predict(MLM_O_MT), col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
cowplot::plot_grid(AM,PM)
cowplot::plot_grid(AT,PT)
-DV: Pain Mean Toward Bias
re_P_MT <- lmer(RT ~ (1|Subject), data = df_long_pain_mean_toward)
performance::icc(re_P_MT)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.713
## Conditional ICC: 0.713
MLM_P_MT <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_pain_mean_toward)
#Multiple Degree-of-Freedome F-Tests
anova(MLM_P_MT, type = "III")
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## Session 821.77 821.77 1 26.945 1.2168 0.2797
## Condition 1851.76 925.88 2 82.606 1.3710 0.2596
## Session:Condition 1972.03 986.01 2 86.744 1.4600 0.2379
#Means/SDs
df_long_pain_mean_toward %>% select(-Cue, -Bias_Type) %>% group_by(Session, Condition) %>% summarise(M = mean(RT), SD = sd(RT)) %>% arrange(Condition,Session)
## `summarise()` has grouped output by 'Session'. You can override using the
## `.groups` argument.
## # A tibble: 6 × 4
## # Groups: Session [2]
## Session Condition M SD
## <fct> <chr> <dbl> <dbl>
## 1 Pre A 104. 48.4
## 2 Post A 98.7 50.2
## 3 Pre B 109. 40.3
## 4 Post B 117. 52.4
## 5 Pre C 112. 52.6
## 6 Post C 116. 63.5
emmeans::emmeans(MLM_P_MT, specs = c("Session", "Condition"), lmer.df = "asymp")
## Session Condition emmean SE df asymp.LCL asymp.UCL
## Pre A 111 9.82 Inf 91.7 130
## Post A 107 12.19 Inf 83.6 131
## Pre B 105 9.33 Inf 86.8 123
## Post B 121 11.86 Inf 97.8 144
## Pre C 115 9.34 Inf 96.9 133
## Post C 123 11.93 Inf 99.1 146
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
#Parameter Estimates
summary(MLM_P_MT)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
## Data: df_long_pain_mean_toward
##
## REML criterion at convergence: 1295.4
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.86247 -0.50958 -0.05566 0.35560 2.93915
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## Subject (Intercept) 1567.1 39.59
## SessionPost 406.0 20.15 0.64
## Residual 675.3 25.99
## Number of obs: 134, groups: Subject, 27
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 110.895 9.816 46.666 11.298 5.96e-15 ***
## SessionPost -3.413 9.317 83.654 -0.366 0.715
## ConditionB -5.783 8.208 87.169 -0.705 0.483
## ConditionC 4.279 8.211 86.990 0.521 0.604
## SessionPost:ConditionB 19.381 11.342 87.833 1.709 0.091 .
## SessionPost:ConditionC 10.753 11.402 88.443 0.943 0.348
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.189
## ConditionB -0.475 0.473
## ConditionC -0.475 0.473 0.572
## SssnPst:CnB 0.328 -0.676 -0.698 -0.393
## SssnPst:CnC 0.325 -0.672 -0.390 -0.691 0.550
#Actual Means
AM <- 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)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Means
PM <- ggplot(df_long_pain_mean_toward, aes(x=Session,y=predict(MLM_P_MT), col = Condition)) +
stat_summary(fun.data = "mean_cl_boot",position = position_dodge(width = .5)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Actual Trajecotires
AT <- ggplot(df_long_pain_mean_toward, aes(x=Session,y=RT, col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Trajectories
PT <- ggplot(df_long_pain_mean_toward, aes(x=Session,y=predict(MLM_P_MT), col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
cowplot::plot_grid(AM,PM)
cowplot::plot_grid(AT,PT)
-DV: Opioid Peak Away Bias
re_O_PA <- lmer(RT ~ (1|Subject), data = df_long_opioid_peak_away)
performance::icc(re_O_PA)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.617
## Conditional ICC: 0.617
MLM_O_PA <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_opioid_peak_away)
## boundary (singular) fit: see help('isSingular')
sort(ranef(MLM_O_PA)$Subject$`(Intercept)`)
## [1] -181.3624025 -148.8958924 -131.9608028 -127.8888276 -118.3420935
## [6] -116.7701290 -116.2226707 -88.6507390 -87.7940955 -73.5644574
## [11] -67.4016424 -60.1517064 -56.5306530 -30.1714909 -0.7864742
## [16] 7.3663944 30.0352105 35.3721756 43.9776723 87.1283895
## [21] 97.0930745 136.2218745 140.3941116 170.7266077 172.8662794
## [26] 215.1177212 270.1945660
sort(ranef(MLM_O_PA)$Subject$Session)
## [1] -33.936972 -27.861760 -24.692825 -23.930867 -22.144459 -21.850310
## [7] -21.747868 -16.588541 -16.428244 -13.765560 -12.612359 -11.255733
## [13] -10.578153 -5.645762 -0.147167 1.378418 5.620261 6.618927
## [19] 8.229209 16.303675 18.168291 25.490167 26.270886 31.946777
## [25] 32.347157 40.253349 50.559462
#Multiple Degree-of-Freedome F-Tests
anova(MLM_O_PA, type = "III")
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## Session 135.7 135.7 1 75.837 0.0105 0.9185
## Condition 26491.3 13245.7 2 105.491 1.0291 0.3609
## Session:Condition 7437.8 3718.9 2 102.397 0.2889 0.7497
#Means/SDs
df_long_opioid_peak_away %>% select(-Cue, -Bias_Type) %>% group_by(Session, Condition) %>% summarise(M = mean(RT), SD = sd(RT)) %>% arrange(Condition,Session)
## `summarise()` has grouped output by 'Session'. You can override using the
## `.groups` argument.
## # A tibble: 6 × 4
## # Groups: Session [2]
## Session Condition M SD
## <fct> <chr> <dbl> <dbl>
## 1 Pre A 329. 170.
## 2 Post A 324. 193.
## 3 Pre B 350. 163.
## 4 Post B 361. 197.
## 5 Pre C 372. 204.
## 6 Post C 351. 179.
emmeans::emmeans(MLM_O_PA, specs = c("Session", "Condition"), lmer.df = "asymp")
## Session Condition emmean SE df asymp.LCL asymp.UCL
## Pre A 340 37.0 Inf 268 413
## Post A 334 40.2 Inf 256 413
## Pre B 335 34.7 Inf 267 403
## Post B 358 38.4 Inf 282 433
## Pre C 377 34.7 Inf 309 445
## Post C 367 38.8 Inf 291 443
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
#Parameter Estimates
summary(MLM_O_PA)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
## Data: df_long_opioid_peak_away
##
## REML criterion at convergence: 1649.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.8671 -0.4296 -0.1134 0.4154 2.9405
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## Subject (Intercept) 17569.4 132.5
## SessionPost 615.2 24.8 1.00
## Residual 12871.3 113.5
## Number of obs: 134, groups: Subject, 27
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 340.128 37.039 58.896 9.183 5.76e-13 ***
## SessionPost -5.845 36.742 101.766 -0.159 0.874
## ConditionB -5.125 35.664 103.712 -0.144 0.886
## ConditionC 37.061 35.688 103.792 1.038 0.301
## SessionPost:ConditionB 28.445 49.077 102.345 0.580 0.563
## SessionPost:ConditionC -4.643 49.285 102.324 -0.094 0.925
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.407
## ConditionB -0.546 0.516
## ConditionC -0.546 0.516 0.570
## SssnPst:CnB 0.376 -0.735 -0.698 -0.390
## SssnPst:CnC 0.373 -0.732 -0.388 -0.691 0.548
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
#Actual Means
AM <- 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)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Means
PM <- ggplot(df_long_opioid_peak_away, aes(x=Session,y=predict(MLM_O_PA), col = Condition)) +
stat_summary(fun.data = "mean_cl_boot",position = position_dodge(width = .5)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Actual Trajectories
AT <- ggplot(df_long_opioid_peak_away, aes(x=Session,y=RT, col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Trajectories
PT <- ggplot(df_long_opioid_peak_away, aes(x=Session,y=predict(MLM_O_PA), col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
cowplot::plot_grid(AM,PM)
cowplot::plot_grid(AT,PT)
-DV: Pain Peak Away Bias
re_P_PA <- lmer(RT ~ (1|Subject), data = df_long_pain_peak_away)
performance::icc(re_P_PA)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.711
## Conditional ICC: 0.711
MLM_P_PA <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_pain_peak_away)
#Multiple Degree-of-Freedome F-Tests
anova(MLM_P_PA, type = "III")
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## Session 5979.7 5979.7 1 23.462 0.6931 0.4135
## Condition 3272.4 1636.2 2 79.920 0.1897 0.8276
## Session:Condition 8763.9 4381.9 2 84.768 0.5079 0.6036
#Means/SDs
df_long_pain_peak_away %>% select(-Cue, -Bias_Type) %>% group_by(Session, Condition) %>% summarise(M = mean(RT), SD = sd(RT)) %>% arrange(Condition, Session)
## `summarise()` has grouped output by 'Session'. You can override using the
## `.groups` argument.
## # A tibble: 6 × 4
## # Groups: Session [2]
## Session Condition M SD
## <fct> <chr> <dbl> <dbl>
## 1 Pre A 334. 189.
## 2 Post A 372. 180.
## 3 Pre B 362. 153.
## 4 Post B 356. 173.
## 5 Pre C 353. 173.
## 6 Post C 342. 187.
emmeans::emmeans(MLM_P_PA, specs = c("Session", "Condition"), lmer.df = "asymp")
## Session Condition emmean SE df asymp.LCL asymp.UCL
## Pre A 349 35.5 Inf 279 418
## Post A 385 37.8 Inf 311 459
## Pre B 347 33.8 Inf 281 413
## Post B 361 36.5 Inf 290 433
## Pre C 364 33.8 Inf 298 430
## Post C 359 36.8 Inf 287 431
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
#Parameter Estimates
summary(MLM_P_PA)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
## Data: df_long_pain_peak_away
##
## REML criterion at convergence: 1614.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.27661 -0.56489 -0.03049 0.41850 2.33591
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## Subject (Intercept) 20760 144.08
## SessionPost 1958 44.25 0.24
## Residual 8627 92.88
## Number of obs: 134, groups: Subject, 27
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 348.594 35.534 46.996 9.810 5.93e-13 ***
## SessionPost 36.423 31.343 87.597 1.162 0.248
## ConditionB -1.559 29.440 83.961 -0.053 0.958
## ConditionC 15.289 29.456 83.712 0.519 0.605
## SessionPost:ConditionB -22.266 40.465 85.894 -0.550 0.584
## SessionPost:ConditionC -40.975 40.655 86.696 -1.008 0.316
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.368
## ConditionB -0.472 0.505
## ConditionC -0.472 0.504 0.574
## SssnPst:CnB 0.327 -0.715 -0.701 -0.395
## SssnPst:CnC 0.324 -0.712 -0.393 -0.694 0.551
#Actual Means
AM <- 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)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Means
PM <- ggplot(df_long_pain_peak_away, aes(x=Session,y=predict(MLM_P_PA), col = Condition)) +
stat_summary(fun.data = "mean_cl_boot",position = position_dodge(width = .5)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Actual Trajectories
AT <- ggplot(df_long_pain_peak_away, aes(x=Session,y=RT, col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Trajectories
PT <- ggplot(df_long_pain_peak_away, aes(x=Session,y=predict(MLM_P_PA), col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
cowplot::plot_grid(AM,PM)
cowplot::plot_grid(AT,PT)
-DV: Opioid Peak Toward Bias
re_O_PT <- lmer(RT ~ (1|Subject), data = df_long_opioid_peak_toward)
performance::icc(re_O_PA)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.617
## Conditional ICC: 0.617
MLM_O_PT <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_opioid_peak_toward)
## boundary (singular) fit: see help('isSingular')
sort(ranef(MLM_O_PT)$Subject$`(Intercept)`)
## [1] -194.327290 -178.191590 -154.997656 -121.204188 -113.633089 -108.762831
## [7] -101.033579 -92.913578 -85.070909 -72.400693 -65.709142 -45.352569
## [13] -37.158593 -35.806099 -13.090863 4.415373 19.858564 30.410808
## [19] 48.473744 54.203466 83.462940 126.889241 173.914037 174.863303
## [25] 207.728061 219.156537 276.276595
sort(ranef(MLM_O_PT)$Subject$Session)
## [1] -25.1047476 -23.0202093 -20.0238322 -15.6581227 -14.6800279 -14.0508491
## [7] -13.0523227 -12.0033163 -10.9901378 -9.3532984 -8.4888305 -5.8590062
## [13] -4.8004431 -4.6257172 -1.6911820 0.5704131 2.5654875 3.9287105
## [19] 6.2622245 7.0024356 10.7824076 16.3925631 22.4676009 22.5902347
## [25] 26.8359660 28.3123876 35.6916118
#Multiple Degree-of-Freedome F-Tests
anova(MLM_O_PA, type = "III")
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## Session 135.7 135.7 1 75.837 0.0105 0.9185
## Condition 26491.3 13245.7 2 105.491 1.0291 0.3609
## Session:Condition 7437.8 3718.9 2 102.397 0.2889 0.7497
#Means/SDs
df_long_opioid_peak_toward %>% select(-Cue, -Bias_Type) %>% group_by(Session, Condition) %>% summarise(M = mean(RT), SD = sd(RT)) %>% arrange(Condition,Session)
## `summarise()` has grouped output by 'Session'. You can override using the
## `.groups` argument.
## # A tibble: 6 × 4
## # Groups: Session [2]
## Session Condition M SD
## <fct> <chr> <dbl> <dbl>
## 1 Pre A 312. 149.
## 2 Post A 362. 179.
## 3 Pre B 370. 170.
## 4 Post B 380. 162.
## 5 Pre C 358. 176.
## 6 Post C 345 188.
emmeans::emmeans(MLM_O_PT, specs = c("Session", "Condition"), lmer.df = "asymp")
## Session Condition emmean SE df asymp.LCL asymp.UCL
## Pre A 332 34.3 Inf 264 399
## Post A 374 36.6 Inf 302 446
## Pre B 359 32.5 Inf 296 423
## Post B 387 35.3 Inf 317 456
## Pre C 372 32.5 Inf 308 436
## Post C 368 35.6 Inf 298 437
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
#Parameter Estimates
summary(MLM_O_PA)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
## Data: df_long_opioid_peak_away
##
## REML criterion at convergence: 1649.3
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.8671 -0.4296 -0.1134 0.4154 2.9405
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## Subject (Intercept) 17569.4 132.5
## SessionPost 615.2 24.8 1.00
## Residual 12871.3 113.5
## Number of obs: 134, groups: Subject, 27
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 340.128 37.039 58.896 9.183 5.76e-13 ***
## SessionPost -5.845 36.742 101.766 -0.159 0.874
## ConditionB -5.125 35.664 103.712 -0.144 0.886
## ConditionC 37.061 35.688 103.792 1.038 0.301
## SessionPost:ConditionB 28.445 49.077 102.345 0.580 0.563
## SessionPost:ConditionC -4.643 49.285 102.324 -0.094 0.925
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.407
## ConditionB -0.546 0.516
## ConditionC -0.546 0.516 0.570
## SssnPst:CnB 0.376 -0.735 -0.698 -0.390
## SssnPst:CnC 0.373 -0.732 -0.388 -0.691 0.548
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
#Actual Means
AM <- 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)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Means
PM <- ggplot(df_long_opioid_mean_toward, aes(x=Session,y=predict(MLM_O_PT), col = Condition)) +
stat_summary(fun.data = "mean_cl_boot",position = position_dodge(width = .5)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Actual Trajecotires
AT <- ggplot(df_long_opioid_mean_toward, aes(x=Session,y=RT, col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Trajectories
PT <- ggplot(df_long_opioid_mean_toward, aes(x=Session,y=predict(MLM_O_PT), col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
cowplot::plot_grid(AM,PM)
cowplot::plot_grid(AT,PT)
-DV: Pain Peak Toward Bias
re_P_PT <- lmer(RT ~ (1|Subject), data = df_long_pain_peak_toward)
performance::icc(re_P_PT)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.699
## Conditional ICC: 0.699
MLM_P_PT <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_pain_peak_toward)
#Multiple Degree-of-Freedome F-Tests
anova(MLM_P_PT, type = "III")
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## Session 2324.3 2324.3 1 25.267 0.3161 0.5789
## Condition 10172.3 5086.2 2 81.690 0.6917 0.5037
## Session:Condition 9286.3 4643.1 2 86.139 0.6314 0.5343
#Means/SDs
df_long_pain_peak_toward %>% select(-Cue, -Bias_Type) %>% group_by(Session, Condition) %>% summarise(M = mean(RT), SD = sd(RT)) %>% arrange(Condition,Session)
## `summarise()` has grouped output by 'Session'. You can override using the
## `.groups` argument.
## # A tibble: 6 × 4
## # Groups: Session [2]
## Session Condition M SD
## <fct> <chr> <dbl> <dbl>
## 1 Pre A 335. 150.
## 2 Post A 332. 163.
## 3 Pre B 347. 123.
## 4 Post B 360. 142.
## 5 Pre C 360. 173.
## 6 Post C 347. 204.
emmeans::emmeans(MLM_O_PT, specs = c("Session", "Condition"), lmer.df = "asymp")
## Session Condition emmean SE df asymp.LCL asymp.UCL
## Pre A 332 34.3 Inf 264 399
## Post A 374 36.6 Inf 302 446
## Pre B 359 32.5 Inf 296 423
## Post B 387 35.3 Inf 317 456
## Pre C 372 32.5 Inf 308 436
## Post C 368 35.6 Inf 298 437
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
#Parameter Estimates
summary(MLM_P_PT)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
## Data: df_long_pain_peak_toward
##
## REML criterion at convergence: 1592.7
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.73146 -0.52681 -0.01424 0.43289 2.40516
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## Subject (Intercept) 14577 120.73
## SessionPost 2432 49.31 0.71
## Residual 7354 85.75
## Number of obs: 134, groups: Subject, 27
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 344.405 30.890 49.966 11.149 3.68e-15 ***
## SessionPost 1.814 29.338 87.748 0.062 0.951
## ConditionB -6.812 27.016 86.422 -0.252 0.802
## ConditionC 25.741 27.031 86.187 0.952 0.344
## SessionPost:ConditionB 31.058 37.270 87.350 0.833 0.407
## SessionPost:ConditionC -6.469 37.452 88.046 -0.173 0.863
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.256
## ConditionB -0.496 0.492
## ConditionC -0.496 0.491 0.571
## SssnPst:CnB 0.342 -0.702 -0.697 -0.391
## SssnPst:CnC 0.339 -0.699 -0.388 -0.690 0.549
#Actual Means
AM <- 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)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Means
PM <- ggplot(df_long_pain_peak_toward, aes(x=Session,y=predict(MLM_P_PT), col = Condition)) +
stat_summary(fun.data = "mean_cl_boot",position = position_dodge(width = .5)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Actual Trajectories
AT <- ggplot(df_long_pain_peak_toward, aes(x=Session,y=RT, col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Trajectories
PT <- ggplot(df_long_pain_peak_toward, aes(x=Session,y=predict(MLM_P_PT), col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
cowplot::plot_grid(AM,PM)
cowplot::plot_grid(AT,PT)
-DV: Opioid Variability Bias
re_O_V <- lmer(RT ~ (1|Subject), data = df_long_opioid_variability)
performance::icc(re_O_V)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.784
## Conditional ICC: 0.784
MLM_O_V <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_opioid_variability)
## boundary (singular) fit: see help('isSingular')
sort(ranef(MLM_O_V)$Subject$`(Intercept)`)
## [1] -53.1622200 -50.5654202 -40.6929811 -40.2688879 -33.3842299 -29.1919852
## [7] -26.7480514 -25.8517364 -23.1962926 -22.2324530 -19.9655169 -14.2731556
## [13] -11.8883608 -4.8898652 0.6480761 0.9987218 2.9273336 13.5194117
## [19] 18.6080781 18.8243394 31.7325266 34.8953570 48.2956552 50.2476616
## [25] 51.6399859 53.4341739 70.5398354
sort(ranef(MLM_O_V)$Subject$Session)
## [1] -5.44770296 -5.18160057 -4.16994012 -4.12648193 -3.42098897 -2.99139622
## [7] -2.74095850 -2.64911023 -2.37699840 -2.27823067 -2.04593046 -1.46261597
## [13] -1.21823841 -0.50108015 0.06641043 0.10234222 0.29997325 1.38537742
## [19] 1.90682936 1.92899035 3.25173364 3.57583900 4.94901047 5.14903883
## [25] 5.29171476 5.47557095 7.22844287
#Multiple Degree-of-Freedome F-Tests
anova(MLM_O_V, type = "III")
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## Session 211.20 211.20 1 80.418 0.5456 0.4623
## Condition 1593.49 796.74 2 103.656 2.0582 0.1329
## Session:Condition 5.46 2.73 2 101.998 0.0071 0.9930
#Means/SDs
df_long_opioid_variability %>% select(-Cue, -Bias_Type) %>% group_by(Session, Condition) %>% summarise(M = mean(RT), SD = sd(RT)) %>% arrange(Condition,Session)
## `summarise()` has grouped output by 'Session'. You can override using the
## `.groups` argument.
## # A tibble: 6 × 4
## # Groups: Session [2]
## Session Condition M SD
## <fct> <chr> <dbl> <dbl>
## 1 Pre A 88.6 42.7
## 2 Post A 92.5 43.4
## 3 Pre B 98.1 30.7
## 4 Post B 95.9 39.5
## 5 Pre C 98.2 48.5
## 6 Post C 97.7 47.3
emmeans::emmeans(MLM_O_V, specs = c("Session", "Condition"), lmer.df = "asymp")
## Session Condition emmean SE df asymp.LCL asymp.UCL
## Pre A 93.8 8.41 Inf 77.3 110
## Post A 96.9 8.97 Inf 79.4 114
## Pre B 94.3 8.09 Inf 78.4 110
## Post B 96.4 8.73 Inf 79.3 114
## Pre C 101.6 8.10 Inf 85.7 117
## Post C 104.1 8.78 Inf 86.9 121
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
#Parameter Estimates
summary(MLM_O_V)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
## Data: df_long_opioid_variability
##
## REML criterion at convergence: 1220.5
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -2.39724 -0.51084 -0.07423 0.45530 2.68996
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## Subject (Intercept) 1317.97 36.30
## SessionPost 13.84 3.72 1.00
## Residual 387.10 19.67
## Number of obs: 134, groups: Subject, 27
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 93.7981 8.4125 41.4107 11.150 4.78e-14 ***
## SessionPost 3.1267 6.3582 101.4801 0.492 0.624
## ConditionB 0.4783 6.2151 102.7932 0.077 0.939
## ConditionC 7.7974 6.2203 102.8389 1.254 0.213
## SessionPost:ConditionB -1.0091 8.5141 101.9806 -0.119 0.906
## SessionPost:ConditionC -0.6090 8.5484 101.9658 -0.071 0.943
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.288
## ConditionB -0.420 0.517
## ConditionC -0.420 0.517 0.572
## SssnPst:CnB 0.289 -0.737 -0.698 -0.391
## SssnPst:CnC 0.286 -0.734 -0.389 -0.690 0.548
## optimizer (nloptwrap) convergence code: 0 (OK)
## boundary (singular) fit: see help('isSingular')
#Actual Means
AM <- ggplot(df_long_opioid_variability, aes(x=Session,y=RT, col = Condition)) +
stat_summary(fun.data = "mean_cl_boot",position = position_dodge(width = .5)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Means
PM <- ggplot(df_long_opioid_variability, aes(x=Session,y=predict(MLM_O_V), col = Condition)) +
stat_summary(fun.data = "mean_cl_boot",position = position_dodge(width = .5)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Actual Trajectories
AT <- ggplot(df_long_opioid_variability, aes(x=Session,y=RT, col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Trajectories
PT <- ggplot(df_long_opioid_variability, aes(x=Session,y=predict(MLM_O_V), col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
cowplot::plot_grid(AM,PM)
cowplot::plot_grid(AT,PT)
-DV: Pain Variability Bias
re_P_V <- lmer(RT ~ (1|Subject), data = df_long_pain_variability)
performance::icc(re_P_V)
## # Intraclass Correlation Coefficient
##
## Adjusted ICC: 0.804
## Conditional ICC: 0.804
MLM_P_V <- lmer(RT ~ Session*Condition + (1 + Session |Subject), data = df_long_pain_variability)
#Multiple Degree-of-Freedome F-Tests
anova(MLM_P_V, type = "III")
## Type III Analysis of Variance Table with Satterthwaite's method
## Sum Sq Mean Sq NumDF DenDF F value Pr(>F)
## Session 515.24 515.24 1 23.801 1.3752 0.2525
## Condition 815.83 407.91 2 78.248 1.0887 0.3417
## Session:Condition 15.49 7.74 2 83.947 0.0207 0.9796
#Means/SDs
df_long_pain_variability %>% select(-Cue, -Bias_Type) %>% group_by(Session, Condition) %>% summarise(M = mean(RT), SD = sd(RT)) %>% arrange(Condition,Session)
## `summarise()` has grouped output by 'Session'. You can override using the
## `.groups` argument.
## # A tibble: 6 × 4
## # Groups: Session [2]
## Session Condition M SD
## <fct> <chr> <dbl> <dbl>
## 1 Pre A 89.4 45.7
## 2 Post A 93.2 44.6
## 3 Pre B 98.2 35.7
## 4 Post B 98.3 43.2
## 5 Pre C 97.3 45.9
## 6 Post C 98.4 54.6
emmeans::emmeans(MLM_P_V, specs = c("Session", "Condition"), lmer.df = "asymp")
## Session Condition emmean SE df asymp.LCL asymp.UCL
## Pre A 95.2 8.74 Inf 78.1 112
## Post A 99.5 9.96 Inf 80.0 119
## Pre B 94.5 8.43 Inf 78.0 111
## Post B 100.3 9.74 Inf 81.2 119
## Pre C 100.5 8.43 Inf 84.0 117
## Post C 105.0 9.79 Inf 85.8 124
##
## Degrees-of-freedom method: asymptotic
## Confidence level used: 0.95
#Parameter Estimates
summary(MLM_P_V)
## Linear mixed model fit by REML. t-tests use Satterthwaite's method [
## lmerModLmerTest]
## Formula: RT ~ Session * Condition + (1 + Session | Subject)
## Data: df_long_pain_variability
##
## REML criterion at convergence: 1228.6
##
## Scaled residuals:
## Min 1Q Median 3Q Max
## -1.7438 -0.4918 -0.1046 0.4235 3.1886
##
## Random effects:
## Groups Name Variance Std.Dev. Corr
## Subject (Intercept) 1480.5 38.48
## SessionPost 149.3 12.22 0.52
## Residual 374.7 19.36
## Number of obs: 134, groups: Subject, 27
##
## Fixed effects:
## Estimate Std. Error df t value Pr(>|t|)
## (Intercept) 95.2362 8.7356 39.4413 10.902 1.81e-13 ***
## SessionPost 4.2747 6.7269 84.8506 0.635 0.527
## ConditionB -0.7355 6.1395 83.3470 -0.120 0.905
## ConditionC 5.2924 6.1429 83.0851 0.862 0.391
## SessionPost:ConditionB 1.5426 8.4454 85.1775 0.183 0.856
## SessionPost:ConditionC 0.2217 8.4874 85.9665 0.026 0.979
## ---
## Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
##
## Correlation of Fixed Effects:
## (Intr) SssnPs CndtnB CndtnC SsP:CB
## SessionPost -0.191
## ConditionB -0.400 0.490
## ConditionC -0.400 0.489 0.574
## SssnPst:CnB 0.277 -0.696 -0.699 -0.395
## SssnPst:CnC 0.275 -0.693 -0.392 -0.692 0.551
#Actual Means
AM <- ggplot(df_long_pain_variability, aes(x=Session,y=RT, col = Condition)) +
stat_summary(fun.data = "mean_cl_boot",position = position_dodge(width = .5)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Means
PM <- ggplot(df_long_pain_variability, aes(x=Session,y=predict(MLM_P_V), col = Condition)) +
stat_summary(fun.data = "mean_cl_boot",position = position_dodge(width = .5)) + ggtitle("Group Means") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Actual Trajectories
AT <- ggplot(df_long_pain_variability, aes(x=Session,y=RT, col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
#Predicted Trajectories
PT <- ggplot(df_long_pain_variability, aes(x=Session,y=predict(MLM_P_V), col = Condition, group=Subject)) +
geom_point(alpha = .03) + geom_line(alpha = .5) + ggtitle("Individual Trajectories") +
theme_light() +
theme(plot.title = element_text(hjust = 0.5))
cowplot::plot_grid(AM,PM)
cowplot::plot_grid(AT,PT)