/
analysis_publication.Rmd
464 lines (374 loc) · 22.5 KB
/
analysis_publication.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
---
title: "Motivation for near-impossibility"
author: "Stef Meliss"
date: "13/06/2022"
output: html_document
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
##################################################################
############################ set ups ############################
##################################################################
# clear workspace
rm(list = ls())
# load libraries and functions
library(ggplot2)
library(psych)
library(reshape2)
library(dplyr)
library(lme4)
library(lmerTest)
library(car)
library(lsmeans)
source("anovakun_482.txt") # anovakun package retrieved from http://riseki.php.xdomain.jp/index.php?ANOVA君%2FANOVA君の使い方
# read in data set from r project (note: download needs to be done firstly)
df <- read.csv("Behaviour.csv")
# ordering data in the same way as in SPM
df$orderedcond <- rep(c(1, 3, 2), each =17)
df <- df[with(df, order(df$orderedcond, df$scan)),]
df$orderedcond <- as.factor(df$orderedcond)
df$orderedcond <- ifelse(df$orderedcond == "1", "No-reward",
ifelse(df$orderedcond == "2", "Reward",
ifelse(df$orderedcond == "3", "Gambling", NA)))
##################################################################################
############################ behavioural assessments ############################
##################################################################################
# a1-a10: 10 questions after session 1 (asked inside the scanner)
# b1-b10: same 10 questions after session 2 (asked inside the scanner)
# c1-c10: combined ratings for both sessions [ created with ci <- (ai + bi)/2 ]
# 1. I am glad to know that the next one is easy
# 2. I am disappointed to know that the next one is easy --> used to create c2r [recoded df$c2r <- car::recode(df$c2, "1=5; 2=4; 3=3; 4=2; 5=1") ]
# 3. I am glad to know that the next one is moderately difficult
# 4. I am disappointed to know that the next one is moderately difficult --> used to create c4r [recoded df$c4r <- car::recode(df$c4, "1=5; 2=4; 3=3; 4=2; 5=1") ]
# 5. I am glad to know that the next one is very difficult
# 6. I am disappointed to know that the next one is very difficult --> used to create c6r [recoded df$c6r <- car::recode(df$c6, "1=5; 2=4; 3=3; 4=2; 5=1") ]
# 7. I am glad to know that the next one is a watchstop trial
# 8. I am disappointed to know that the next one is a watchstop trial --> used to create c8r [recoded df$c8r <- car::recode(df$c8, "1=5; 2=4; 3=3; 4=2; 5=1") ]
# 9. I understand the rule of the experiment
# 10. I am satisfied with the results so far
# POST QUESTIONS ASKED AT THE END OF THE EXPERIMENT
# intrinsic motivation after the scanning
#post1. It was fun to do the easy task
#post2. It was boring to do the easy task (reversely coded)
#post3. It was enjoyable to do the easy task
#post4. It was fun to do the moderately difficult task
#post5. It was boring to do the moderately difficult task (reversely coded)
#post6. It was enjoyable to do the moderately difficult task
#post7. It was fun to do the very difficult task
#post8. It was boring to do the very difficult task (reversely coded)
#post9. It was enjoyable to do the very difficult task
#post10. It was fun to do the watchstop task
#post11. It was boring to do the watchstop task (reversely coded)
#post12. It was enjoyable to do the watchstop task
# calculate the score of intrinsic motivation for each level of chance of success
df$mot_high <- (8 + df$post1 - df$post2 + df$post3)/3 # high chance of success
df$mot_mod <- (8 + df$post4 - df$post5 + df$post6)/3 # moderate chance of success
df$mot_low <- (8 + df$post7 - df$post8 + df$post9)/3 # extremely-low chance of success
df$mot_ws <- (8 + df$post10 - df$post11 + df$post12)/3 # watch stop
# calculate Cronbach's alpha for the items for capturing intrinsic motivation for each level of success
mot_high <- df[,c("post1", "post2", "post3")] # high chance of success
mot_mod <- df[,c("post4", "post5", "post6")] # moderate chance of success
mot_low <- df[,c("post7", "post8", "post9")] # extremely-low chance of success
mot_ws <- df[,c("post10", "post11", "post12")] # watch stop
# difficulty
#post13. The easy task was difficult
#post14. The moderately difficult task was difficult
#post15. The very difficult task was difficult
# Others
#post16. The experiment was sleepy
#post17. I concentrated on the experiment
#post18. I was unable to focus on the experiment
#post19. To be honest, I was totally demotivated
#post20. I really did not like the experiment
# post happiness
#post21. I felt happy when I see the cue of the easy task
#post23. I felt happy when I see the cue of the moderately difficult task
#post25. I felt happy when I see the cue of the very difficult task
#post27 I felt happy when I see the cue of the watchstop task
# post dissappointment
#post22. I got dissappointed when I see the cue of the easy task
#post24. I got dissappointed when I see the cue of the moderately difficult task
#post26. I got dissappointed when I see the cue of the very difficult task
#post28. I got dissappointed when I see the cue of the watchstop task
# calculate rewarding value: recode disappointment items and combine them with happiness
df$post22_r <- car::recode(df$post22, "1=7; 2=6; 3=5; 4=4; 5=3; 6=2; 7=1" )
df$post24_r <- car::recode(df$post24, "1=7; 2=6; 3=5; 4=4; 5=3; 6=2; 7=1" )
df$post26_r <- car::recode(df$post26, "1=7; 2=6; 3=5; 4=4; 5=3; 6=2; 7=1" )
df$post28_r <- car::recode(df$post28, "1=7; 2=6; 3=5; 4=4; 5=3; 6=2; 7=1" )
# calculate the score of reward value for each level of chance of success
df$val_high <- (df$post21 + df$post22_r)/2 # high chance of success
df$val_mod <- (df$post23 + df$post24_r)/2 # moderate chance of success
df$val_low <- (df$post25 + df$post26_r)/2 # extremely-low chance of success
df$val_ws <- (df$post27 + df$post28_r)/2 # watch stop
#######################################################################
########################## 3 x 3 MIXED ANOVA ########################
#######################################################################
# between factor group: no-reward, reward, or gambling
# within-factor chance of success: high chance, moderate chance, or extremely-low chance
# DEPENDENT VARIABLE 1: ratings of intrinsic motivation #
# create data frame in long format
df_mot <- melt(df, id.vars = c("id", "cond"), measure.vars = c("mot_low", "mot_mod", "mot_high") )
names(df_mot) <- c("id", "cond", "measurement", "rating")
df_mot$chance_success <- ifelse(df_mot$measurement == "mot_low", "extremely-low",
ifelse(df_mot$measurement == "mot_mod", "moderate",
ifelse(df_mot$measurement == "mot_high", "high",NA)))
# specify anovakun
anovakun_mot <- df_mot
anovakun_mot <- anovakun_mot[,c("id", "cond", "chance_success", "rating")]
# DEPENDENT VARIABLE 2: ratings of rewarding value #
# create data frame in long format
df_val <- melt(df, id.vars = c("id", "cond"), measure.vars = c("val_low", "val_mod", "val_high") )
names(df_val) <- c("id", "cond", "measurement", "rating")
df_val$chance_success <- ifelse(df_val$measurement == "val_low", "extremely-low",
ifelse(df_val$measurement == "val_mod", "moderate",
ifelse(df_val$measurement == "val_high", "high",NA)))
# specify anovakun
anovakun_val <- df_val
anovakun_val <- anovakun_val[,c("id", "cond", "chance_success", "rating")]
anovakun(anovakun_val, "AsB", 3, 3, long = T, geta = T)
# read in values from .txt file
left <- read.delim("estimates_left_peak_voxel.txt", header = F, sep = "\t")
right <- read.delim("estimates_right_peak_voxel.txt", header = F, sep = "\t")
# # add values to data set
# df$left_low <- left$V1 # extremely-low chance of success
# df$left_mod <- left$V2 # moderate chance of success
# df$left_high <- left$V3 # high chance of success
#
# df$right_low <- right$V1 # extremely-low chance of success
# df$right_mod <- right$V2 # moderate chance of success
# df$right_high <- right$V3 # high chance of success
# add values to data set
df$left_low[1:17] <- left$V1[ 1:17] # extremely-low chance of success - control
df$left_mod[1:17] <- left$V1[18:34] # moderate chance of success - control
df$left_high[1:17] <- left$V1[35:51] # high chance of success - control
df$left_low[18:34] <- left$V1[52:68] # extremely-low chance of success - reward
df$left_mod[18:34] <- left$V1[69:85] # moderate chance of success - reward
df$left_high[18:34] <- left$V1[86:102] # high chance of success - reward
df$left_low[35:51] <- left$V1[103:119] # extremely-low chance of success - gambling
df$left_mod[35:51] <- left$V1[120:136] # moderate chance of success - gambling
df$left_high[35:51] <- left$V1[137:153] # high chance of success - gambling
df$right_low[1:17] <- right$V1[ 1:17] # extremely-low chance of success - control
df$right_mod[1:17] <- right$V1[18:34] # moderate chance of success - control
df$right_high[1:17] <- right$V1[35:51] # high chance of success - control
df$right_low[18:34] <- right$V1[52:68] # extremely-low chance of success - reward
df$right_mod[18:34] <- right$V1[69:85] # moderate chance of success - reward
df$right_high[18:34] <- right$V1[86:102] # high chance of success - reward
df$right_low[35:51] <- right$V1[103:119] # extremely-low chance of success - gambling
df$right_mod[35:51] <- right$V1[120:136] # moderate chance of success - gambling
df$right_high[35:51] <- right$V1[137:153] # high chance of success - gambling
```
# Cronbach's Alpha for intrinsic motivation scale and correlation of rewarding value items
```{r cars}
# calculate the correlations between the items
cor(df$post21, df$post22_r) # extremely-low chance of success
cor(df$post23, df$post24_r) # moderate chance of success
cor(df$post25, df$post26_r) # high chance of success
cor(df$post27, df$post28_r) # watch stop
# calculate Cronbach's alpha for the items for capturing intrinsic motivation for each level of success
# high chance of success
psych::alpha(mot_high, keys = "post2") # post2 reversely coded
# moderate chance of success
alpha(mot_mod, keys = "post5") # post5 reversely coded
# extremely-low chance of success
alpha(mot_low, keys = "post8") # post8 reversely coded
# watch stop
alpha(mot_ws, keys = "post11") # post11 reversely coded
```
# 3 x 3 MIXED ANOVA
between factor group: no-reward, reward, or gambling
within-factor chance of success: high chance, moderate chance, or extremely-low chance
## DEPENDENT VARIABLE 1: ratings of intrinsic motivation
```{r anovakun_mot, echo=T}
anovakun(anovakun_mot, "AsB", 3, 3, long = T, geta = T)
```
# 3 x 3 MIXED ANOVA
between factor group: no-reward, reward, or gambling
within-factor chance of success: high chance, moderate chance, or extremely-low chance
## DEPENDENT VARIABLE 2: ratings of rewarding value
```{r anovakun_val, echo=T}
anovakun(anovakun_val, "AsB", 3, 3, long = T, geta = T)
```
# Trend Analysis whole sample
## DEPENDENT VARIABLE 1: ratings of intrinsic motivation (LME)
```{r trend_mot, include=TRUE, echo=TRUE}
# define variable contrast:
# examining the orthogonal linear and the quadratic effects of chance of success for each group.
df_mot$contrast <-
# no-reward group: resulting in a decrease in intrinsic motivation as chance of success increases
ifelse(df_mot$cond == "No-reward" & df_mot$chance_success == "extremely-low", 1,
ifelse(df_mot$cond == "No-reward" & df_mot$chance_success == "moderate", 0,
ifelse(df_mot$cond == "No-reward" & df_mot$chance_success == "high", -1,
# reward group: resulting in a quadratic relationship between intrinsic motivation and chance of success
ifelse(df_mot$cond == "Reward" & df_mot$chance_success == "extremely-low", -1,
ifelse(df_mot$cond == "Reward" & df_mot$chance_success == "moderate", 2,
ifelse(df_mot$cond == "Reward" & df_mot$chance_success == "high", -1,
# resulting in an increase in intrinsic motivation as chance of success increases in gambling group
ifelse(df_mot$cond == "Gambling" & df_mot$chance_success == "extremely-low", -1,
ifelse(df_mot$cond == "Gambling" & df_mot$chance_success == "moderate", 0,
ifelse(df_mot$cond == "Gambling" & df_mot$chance_success == "high", 1, NA
)))))))))
# compute LME with the defined contrast as predictor for intrinsic motivation across all groups
trend_mot <- lmer(rating ~ 1 + contrast + (1 + contrast | id), data = df_mot, REML = F)
summary(trend_mot)
```
# Trend Analysis whole sample
## DEPENDENT VARIABLE 1: ratings of intrinsic motivation (afex)
```{r trend_mot_afex, include=TRUE, echo=TRUE}
# specify aov_car
aovcar_mot <- afex::aov_car(rating ~ cond*measurement + Error(id / measurement), data = df_mot) # specify model
aovcar_mot
lsm_mot <- lsmeans(aovcar_mot, specs = ~ cond*measurement) # get mean values per measurement and group
lsm_mot
# look at contrast: gambling-low=-1, control-low=1, reward-low=-1; gambling-mod=0, control-mod=0, reward-mod=2; gambling-high=1, control-high=-1, reward-high=-1
contrast(lsm_mot, list(mycon = c(-1,1,-1,0,0,2,1,-1,-1)))
```
# Trend Analysis within each group
## DEPENDENT VARIABLE 1: ratings of intrinsic motivation (afex)
```{r trend_mot_afex_group, include=TRUE, echo=TRUE}
# specify the aov_car and test for polynomial contrasts for each group
# no-reward
df_mot_c <- subset(df_mot, df_mot$cond == "No-reward") # subset data
aovcar_mot_c <- afex::aov_car(rating ~ measurement + Error(id / measurement), data = df_mot_c) # specify model
aovcar_mot_c
lsm_mot_c <- lsmeans(aovcar_mot_c, specs = ~ measurement) # get mean values per measurement
lsm_mot_c
contrast(lsm_mot_c, "poly") # look at polynomial contrasts
# reward
df_mot_r <- subset(df_mot, df_mot$cond == "Reward") # subset data
aovcar_mot_r <- afex::aov_car(rating ~ measurement + Error(id / measurement), data = df_mot_r) # specify model
aovcar_mot_r
lsm_mot_r <- lsmeans(aovcar_mot_r, specs = ~ measurement) # get mean values per measurement
lsm_mot_r
contrast(lsm_mot_r, "poly") # look at polynomial contrasts
# gambling
df_mot_g <- subset(df_mot, df_mot$cond == "Gambling") # subset data
aovcar_mot_g <- afex::aov_car(rating ~ measurement + Error(id / measurement), data = df_mot_g) # specify model
aovcar_mot_g
lsm_mot_g <- lsmeans(aovcar_mot_g, specs = ~ measurement) # get mean values per measurement
lsm_mot_g
contrast(lsm_mot_g, "poly") # look at polynomial contrasts
```
# Trend Analysis whole sample
## DEPENDENT VARIABLE 2: ratings of rewarding value (LME)
```{r trend_val, include=TRUE, echo=TRUE}
# define variable contrast:
# examining the orthogonal linear effects of chance of success for each group
df_val$contrast <-
# no-reward group: resulting in a decrease in rewarding value as chance of success increases
ifelse(df_val$cond == "No-reward" & df_val$chance_success == "extremely-low", 1,
ifelse(df_val$cond == "No-reward" & df_val$chance_success == "moderate", 0,
ifelse(df_val$cond == "No-reward" & df_val$chance_success == "high", -1,
# reward group: resulting in an increase in rewarding value as chance of success increases
ifelse(df_val$cond == "Reward" & df_val$chance_success == "extremely-low", -1,
ifelse(df_val$cond == "Reward" & df_val$chance_success == "moderate", 0,
ifelse(df_val$cond == "Reward" & df_val$chance_success == "high", 1,
# gambling group: resulting in an increase in rewarding value as chance of success increases
ifelse(df_val$cond == "Gambling" & df_val$chance_success == "extremely-low", -1,
ifelse(df_val$cond == "Gambling" & df_val$chance_success == "moderate", 0,
ifelse(df_val$cond == "Gambling" & df_val$chance_success == "high", 1, NA
)))))))))
# compute LME with the defined contrast as predictor for rewarding value across all groups
trend_val <- lmer(rating ~ 1 + contrast + (1 + contrast | id), data = df_val, REML = F)
summary(trend_val)
```
# Trend Analysis whole sample
## DEPENDENT VARIABLE 2: ratings of rewarding value (afex)
```{r trend_val_afex, include=TRUE, echo=TRUE}
# specify aov_car
aovcar_val <- afex::aov_car(rating ~ cond*measurement + Error(id / measurement), data = df_val) # specify model
aovcar_val
lsm_val <- lsmeans(aovcar_val, specs = ~ cond*measurement) # get mean values per measurement and group
lsm_val
# look at contrast: gambling-low=-1, control-low=1, reward-low=-1; gambling-mod=0, control-mod=0, reward-mod=0; gambling-high=1, control-high=-1, reward-high=1
contrast(lsm_val, list(mycon = c(-1,1,-1,0,0,0,1,-1,1)))
```
# Trend Analysis within each group
## DEPENDENT VARIABLE 2: ratings of rewarding value (afex)
```{r trend_val_afex_group, include=TRUE, echo=TRUE}
# specify the aov_car and test for polynomial contrasts for each group
# no-reward
df_val_c <- subset(df_val, df_val$cond == "No-reward") # subset data
aovcar_val_c <- afex::aov_car(rating ~ measurement + Error(id / measurement), data = df_val_c) # specify model
aovcar_val_c
lsm_val_c <- lsmeans(aovcar_val_c, specs = ~ measurement) # get mean values per measurement
lsm_val_c
contrast(lsm_val_c, "poly") # look at polynomial contrasts
# reward
df_val_r <- subset(df_val, df_val$cond == "Reward") # subset data
aovcar_val_r <- afex::aov_car(rating ~ measurement + Error(id / measurement), data = df_val_r) # specify model
aovcar_val_r
lsm_val_r <- lsmeans(aovcar_val_r, specs = ~ measurement) # get mean values per measurement
lsm_val_r
contrast(lsm_val_r, "poly") # look at polynomial contrasts
# gambling
df_val_g <- subset(df_val, df_val$cond == "Gambling") # subset data
aovcar_val_g <- afex::aov_car(rating ~ measurement + Error(id / measurement), data = df_val_g) # specify model
aovcar_val_g
lsm_val_g <- lsmeans(aovcar_val_g, specs = ~ measurement) # get mean values per measurement
lsm_val_g
contrast(lsm_val_g, "poly") # look at polynomial contrasts
```
# GRAPHS
```{r graphs, echo=FALSE, fig.align = "center", out.width = '100%'}
#################################################################################
############################ code to create Figure 2 ############################
#################################################################################
# define variables used in the graph
varWithin <- "Chance of success" #fill
levelWithinReordered <- c("High", "Moderate", "Extremely-low")
groupNames <- c("No-reward", "Reward", "Gambling")
title <- c("(A) Intrinsic motivation", "(B) Rewarding value", "(C) Activation pattern at (9 5 -8) and (-9 5 -8)")
title <- c("(A) Intrinsic motivation", "(B) Rewarding value", "(C) Activation pattern at (10 6 -10) and (-8 6 -10)")
xLab <- "Experimental group"
yLab <- c("Rating", "Contrast estimate SW - WS")
titleSize <- 16
axisSize <- 12
## (A) INTRINSIC MOTIVATION ##
# get descriptes of the ratings of intrinsic motivation for each group
mot <- describeBy(df[, c( "mot_high", "mot_mod", "mot_low")], group=df$cond)
# combine the ratings for each group in a data frama
graph_mot <- as.data.frame(rbind(mot$`No-reward`, mot$Reward, mot$Gambling))
graph_mot$cond <- rep(groupNames, each = 3)
graph_mot$vars <- as.factor(graph_mot$vars)
levels(graph_mot$vars) <- levelWithinReordered
# use ggplot to create a bar graph including SE
outg_A <- ggplot(graph_mot, aes(cond, mean, fill = vars)) + theme_classic()
outg_A <- outg_A + geom_bar(stat="identity", position="dodge") + geom_errorbar(aes(ymin=mean-se, ymax=mean+se), width=.1, position=position_dodge(0.9)) +
scale_x_discrete(limits=groupNames) + labs(x=xLab, y=yLab[1], fill = varWithin, title = title[1]) +
theme(axis.text=element_text(size=axisSize), axis.title=element_text(size=axisSize, face="bold"), title=element_text(size = titleSize, face="bold"), legend.title = element_text(size=axisSize), legend.text = element_text(size = axisSize)) +
coord_cartesian(ylim = c(1, 7)) + scale_fill_brewer(palette = 14)
outg_A
## (B) REWRADING VALUE ##
# get descriptes of the ratings of rewarding value for each group
val <- describeBy(df[, c("val_high", "val_mod", "val_low")], group=df$cond)
# combine the ratings for each group in a data frama
outposgraphValue <- as.data.frame(rbind(val$`No-reward`, val$Reward, val$Gambling))
outposgraphValue$cond <-rep(groupNames, each = 3)
outposgraphValue$vars <- as.factor(outposgraphValue$vars)
levels(outposgraphValue$vars) <- levelWithinReordered
# use ggplot to create a bar graph including SE
outg_B <- ggplot(outposgraphValue, aes(cond, mean, fill = vars)) + theme_classic()
outg_B <- outg_B + geom_bar(stat="identity", position="dodge") + geom_errorbar(aes(ymin=mean-se, ymax=mean+se), width=.1, position=position_dodge(0.9)) +
scale_x_discrete(limits=groupNames) + labs(x=xLab, y=yLab[1], fill = varWithin, title = title[2]) +
theme(axis.text=element_text(size=axisSize), axis.title=element_text(size=axisSize, face="bold"), title=element_text(size = titleSize, face="bold"), legend.title = element_text(size=axisSize), legend.text = element_text(size = axisSize)) +
coord_cartesian(ylim = c(1, 7)) + scale_fill_brewer(palette = 14)
outg_B
## (C) ACTIVATION PATTERN ##
# computing average between left and right peak voxel
df$avg_low <- (df$left_low + df$right_low)/2
df$avg_mod <- (df$left_mod + df$right_mod)/2
df$avg_high <- (df$left_high + df$right_high)/2
# creating data frame for plotting purposes
peak <- describeBy(df[, c("avg_high", "avg_mod", "avg_low" )], group=df$cond)
graph_peak <- as.data.frame(rbind(peak$`No-reward`, peak$Reward, peak$Gambling))
graph_peak$cond <- rep(groupNames, each = 3)
graph_peak$vars <- as.factor(graph_peak$vars)
levels(graph_peak$vars) <- levelWithinReordered
# plotting contrast estimates
outg_C <- ggplot(graph_peak, aes(cond, mean, fill = vars)) + theme_classic()
outg_C <- outg_C + geom_bar(stat="identity", position="dodge") + geom_errorbar(aes(ymin=mean-se, ymax=mean+se), width=.1, position=position_dodge(0.9)) +
scale_x_discrete(limits=groupNames) + labs(x=xLab, y=yLab[2], fill = varWithin, title = title[3]) +
theme(axis.text=element_text(size=axisSize), axis.title=element_text(size=axisSize, face="bold"), title=element_text(size = titleSize, face="bold"), legend.title = element_text(size=axisSize), legend.text = element_text(size = axisSize)) +
coord_cartesian(ylim = c(-1, 11)) + scale_fill_brewer(palette = 14)
outg_C
```