-
Notifications
You must be signed in to change notification settings - Fork 0
/
deception-game_final.Rmd
278 lines (209 loc) · 8.96 KB
/
deception-game_final.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
---
title: "deception game - final analysis"
output: html_document
---
```{r setup, include=FALSE, echo = FALSE, message = FALSE}
knitr::opts_chunk$set(echo = TRUE,
warning = FALSE,
message = FALSE,
collapse = TRUE,
cache = TRUE,
dev.args = list(bg = 'transparent'),
fig.align ='center',
fig.height = 3,
fig.widht = 4)
require(rmdformats)
require(tidyverse)
require(faintr)
require(brms)
options(mc.cores = parallel::detectCores())
theme_set(theme_bw() + theme(plot.background=element_blank()))
```
# Loading and inspecting the data
```{r}
raw_data <- read_csv("results_285_deception-game-final_Group+12-3.csv") #load data
show(raw_data) #show tibble with data
```
### General properties of the data
#### Mean time spent on experiment
```{r}
raw_data %>% pull(timeSpent) %>% summary()
```
#### Overview of reaction times for all trials
```{r}
raw_data %>%
ggplot(aes(x = RT)) +
geom_histogram(binwidth = 500, color = "darkblue", fill = "lightblue") +
xlim(0,60000)
```
#### Plot of important variables
```{r}
opponent_prop <- raw_data %>%
filter(trial_name == "Main Trials", condition == "opponent") %>%
select(condition, cue, response) %>%
count(cue, response) %>%
mutate(prop = n/sum(n/3))
teammate_prop <- raw_data %>%
filter(trial_name == "Main Trials", condition == "teammate") %>%
select(condition, cue, response) %>%
count(cue, response) %>%
mutate(prop = n/sum(n/3))
```
```{r}
opponent_prop %>%
ggplot(aes(x = cue, y = prop, fill = response)) +
geom_bar(stat = "identity",position = "dodge", width = 0.5) +
scale_fill_brewer(palette = "Blues") +
ylim(0, 1) +
labs(
x = "cues",
y = "proportions",
title = "Receiver choice in the deception Game",
subtitle = "OPPONENT condition"
)
```
```{r}
teammate_prop %>%
ggplot(aes(x = cue, y = prop, fill = response)) +
geom_bar(stat = "identity", position = "dodge", width = 0.5, ) +
scale_fill_brewer(palette = "Blues") +
ylim(0, 1) +
labs(
x = "cues",
y = "proportions",
title = "Receiver choices in the deception game",
subtitle = "TEAMMATE condition"
)
```
# Summarizing and cleaning the data
We shorten the data by only selecting relevant variables
```{r}
short_data <- raw_data %>%
select(submission_id, RT, condition, cue, response, timeSpent, trial_name, age, gender) # select only necessary data
head(short_data)
```
## Individual-level
### Individual-level reaction times
We take a look at the reaction times of every participant
```{r}
dg_individual_summary <- short_data %>%
filter(trial_name == "Main Trials") %>% # look at only data from main trials
group_by(submission_id) %>% # calculate mean RT for each individual
summarize(mean_RT = mean(RT))
head(dg_individual_summary)
```
### Individual-level error rates
We look at the error rates of every participant. The error rate is dependent on whether the participants choose the response truth when presented with an informative cue, independent of the condition. They need to pass 10 out of 10 in order to get an error rate of 1. Only participants with an error rate of 1 will be included in the final analysis, because otherwise we can conclude that they did not understand the task properly.
```{r}
error_rates <- short_data %>%
filter(trial_name == "Main Trials", cue == "helpful") %>% # only main trials with helpful cue are important
group_by(submission_id) %>%
summarise(error_rate = sum(response == "truth") / 10) # error rate dependent on how often participant chooses truth when helpful cue is given
dg_individual_summary <- full_join(dg_individual_summary,error_rates, by = "submission_id")
head(dg_individual_summary)
```
### Plot of summary information
Summary information with mean reaction times and error rates
```{r}
dg_individual_summary %>%
ggplot(aes(x = mean_RT, y = error_rate)) +
geom_point()
```
Summary information with participants highlighted that will be excluded. They were excluded either because their mean reaction time was to fast ( mean reaction time > 3 seconds ) indicating that the participant did not really think about his/her answer or because their error rate was smaller than 1.
```{r}
# add column outlier that indicates which participants to exclude later on
dg_individual_summary <- dg_individual_summary %>%
mutate(outlier = case_when(mean_RT < 3000 ~ TRUE, # outlier if mean RT < 3 seconds
error_rate < 1 ~ TRUE, # outlier if error rate < 1
TRUE ~ FALSE))
# plot summary information with outliers highlighted as red squares
dg_individual_summary %>%
ggplot(aes(x = mean_RT, y = error_rate)) +
geom_point() +
geom_point(data = filter(dg_individual_summary, outlier == TRUE),
color = "firebrick", shape = "cross", size = 5)
```
### Remove participants identified as outlier
```{r, message=TRUE}
d <- full_join(short_data, dg_individual_summary, by = "submission_id") # merge the tibbles
d <- filter(d, outlier == FALSE) # remove every participant identified as outlier
message(
"We excluded ", sum(dg_individual_summary$outlier) ,
" participants for suspicious mean RTs and higher error rates."
)
```
## Trial-level
### Trial-level reaction times
We take a look at the overall distribution of reaction times, since it is conceivable that individual trials resulted in early accidental key presses.
```{r}
d %>%
filter(trial_name == "Main Trials") %>%
ggplot(aes(x = RT)) +
geom_histogram(binwidth = 1000, color = "darkblue", fill = "lightblue") +
xlim(0,60000) # limits in order to get good visualization
```
We take a look at how many trials take longer than 1 minute for trials to acknowledge all data
```{r}
d %>%
filter(RT > 60000) %>%
count()
```
We decided that every trial with a reaction time smaller than 2 seconds will be excluded, because it indicates that the person did not think about what to choose properly and rather choose a random map accidentally.
```{r}
d_cleaned <- filter(d, trial_name == "Main Trials", RT > 2000)
```
Find data about participants' age
```{r}
d_cleaned %>% select(age) %>% summary()
```
## Main data
### Clean main data
```{r}
d_cleaned %>% filter( response != "decoy")
```
### Overview of counts important for hypothesis
```{r}
lure_misleading_tibble <- d_cleaned %>%
filter(cue == "misleading", response == "lure") %>%
group_by(condition) %>%
summarise(lure_misleading = n())
lure_uninformative_tibble <- d_cleaned %>%
filter(cue == "uninformative", response == "lure" ) %>%
group_by(condition) %>%
summarise(lure_uninformative = n())
merge(lure_misleading_tibble,lure_uninformative_tibble)
```
Participants in the opponent condition when represented with misleading and when represented with uninformative evidence choose the lure less often than participants in the teammate condition.
# Data analysis
## Brm model (logistic regression with multiple predictors)
We choose a logistic regression model in order to test our hypotheses for significant evidence, since we have a binary categorical dependent variable.
```{r}
d_brm<- brm(
# specify what to explain in terms of what
# using the formula syntax
formula = response ~ cue * condition,
# which data to use
data = d_cleaned,
family = 'categorical'
)
```
```{r}
summary(d_brm)
```
## Hypothesis testing
1 Hypothesis:
Participants in the teammate condition are significantly more likely to choose the Lure when presented with misleading evidence than participants in the opponent condition.
--> (lure, misleading, teammate) > (lure, misleading, opponent)
= (lure, misleading, teammate) - (lure, misleading, opponent) > 0
```{r}
hypothesis(d_brm,"(mulure_Intercept + mulure_conditionteammate + mulure_cuemisleading + mulure_cuemisleading:conditionteammate) - (mulure_Intercept + mulure_cuemisleading) > 0")
```
The evidence ratio of suggests strong evidence for the hypothesis that participants in the teammate condition are significantly more likely to choose the Lure when presented with misleading evidence than participants in the opponent condition.
2 Hypothesis:
Participants in the teammate condition are significantly more likely to choose the Lure when presented with uninformative evidence than participants in the opponent condition
--> (lure, uninformative, teammate) > (lure, uninformative, opponent)
= (lure, uninformative, teammate) - (lure, uninformative, opponent) > 0
```{r}
hypothesis(d_brm,"(mulure_Intercept + mulure_cueuninformative + mulure_conditionteammate + mulure_cueuninformative:conditionteammate) - (mulure_Intercept + mulure_cueuninformative) > 0")
```
The evidence ratio suggests no significant evidence for the hypothesis that participants in the teammate condition are significantly more likely to choose the Lure when presented with uninformative evidence than participants in the opponent condition.