generated from psych251/rescue_template
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.Rhistory
512 lines (512 loc) · 21.4 KB
/
.Rhistory
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
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
summarise(mean_correct = mean(sub_mean_correct),
sd_correct = sd(sub_mean_correct),
n_obs = length(sub_mean_correct),
sem = sd_correct / sqrt(n_obs),
ci = sem * 1.96)
sgf_sub_means
sgf_group_means
sgf_sub_means <- sgf |>
group_by(item, condition) |>
summarise(sub_mean_correct = mean(correct))
sgf_group_means <- sgf_sub_means |>
group_by(item, condition) |>
summarise(mean_correct = mean(sub_mean_correct),
sd_correct = sd(sub_mean_correct),
n_obs = length(sub_mean_correct),
sem = sd_correct / sqrt(n_obs),
ci = sem * 1.96)
sgf_sub_means
sgf_group_means
sgf_wide <- read_csv("www/data/sgf_wide.csv")
sgf_wide <- read_csv("www/data/sgf_wide.csv")
sgf_wide <- read_csv("/www/data/sgf_wide.csv")
sgf_wide <- read_csv("sgf_wide.csv")
sgf_wide <- read_csv("www/data/sgf_wide.csv")
sgf <- read_csv("www/data/stiller_scales_data.csv")
sgf_wide <- read_csv("sgf_wide.csv")
sgf_wide <- read_csv("www/data/sgf_wide.csv")
sgf_wide <- read_csv("www/data/sgf_wide.csv")
?pivot_wider
sgf
sgf_wide <- sgf |>
pivot_wider(names_from = "item",
values_from = "correct")
sgf_wide
library(tidyverse)
load("data/KenyaData.RData")
scale.means = function (df, ..., na.rm=FALSE) {
vars = unlist(list(...))
mean_vars = rowMeans(df[,vars], na.rm=na.rm)
return(mean_vars)
}
for (var in c(k1_df$sel.con, k1_df$sel.pers, k1_df$sel.com,
k1_df$sel.prob, k1_df$sel.bett)) {
var[var < 0] <- NA
}
k1_df$sel.score.z <- scale(k1_df$sel.score)
k1_df$sel.score.avg <- scale.means(k1_df, "sel.con", "sel.pers", "sel.com",
"sel.prob", "sel.bett", na.rm = T)
k1_df$sel.score <- scale(k1_df$sel.con) + scale(k1_df$sel.pers) +
scale(k1_df$sel.com) + scale(k1_df$sel.prob) + scale(k1_df$sel.bett)
k1_df$sel.score.z <- scale(k1_df$sel.score)
ggplot(k1_df, aes(x = ...)) +
geom_histogram()
ggplot(k1_df, aes(x = sel.score)) +
geom_histogram()
ggplot(k1_df, aes(x = sel.score), fill = treat) +
geom_histogram()
ggplot(k1_df, aes(x = sel.score), fill = treat) +
geom_histogram()
ggplot(k1_df, aes(x = sel.score, fill= factor(treat))) +
geom_histogram()
ggplot(k1_df, aes(x = vid.num, fill= factor(treat))) +
geom_histogram()
ggplot(k1_df, aes(x = sel.score, facet_wrap(~treat))) +
geom_histogram()
ggplot(k1_df, aes(x = sel.score), facet_wrap(~treat)) +
geom_histogram()
ggplot(k1_df, aes(x = sel.score)) + facet_wrap(~treat) +
geom_histogram()
ggplot(k1_df, aes(x = vid.num)) + facet_wrap(~treat) +
geom_histogram()
ggplot(k1_df, aes(x = sel.score)) + facet_wrap(~treat) +
geom_histogram()
ggplot(k1_df, aes(x = vid.num)) + facet_wrap(~treat) +
geom_histogram()
ggplot(k1_df, aes(x = sel.score)) + facet_wrap(~treat) +
geom_histogram(bins = 2)
ggplot(k1_df, aes(x = sel.score)) + facet_wrap(~treat) +
geom_histogram()
ggplot(k1_df, aes(x = sel.score)) + facet_wrap(~treat) +
geom_histogram(bins = 10)
ggplot(k1_df, aes(x = sel.score)) + facet_wrap(~treat) +
geom_histogram(bins = 5)
ggplot(k1_df, aes(x = sel.score)) + facet_wrap(~treat) +
geom_histogram(bins = 4)
ggplot(k1_df, aes(x = sel.score)) + facet_wrap(~treat) +
geom_histogram(bins = 30)
ggplot(k1_df, aes(x = sel.score)) + facet_wrap(~treat) +
geom_histogram(bins = 300)
ggplot(k1_df, aes(x = sel.score)) + facet_wrap(~treat) +
geom_histogram(bins = 50)
ggplot(k1_df, aes(x = sel.score)) + facet_wrap(~treat) +
geom_histogram(bins = 30)
?summarise
k1_df %>%
group_by(treat) %>%
summarise(VidNum = mean(vid.num)) %>%
ggplot(aes(x = treat, y = VidNum) + geom_col(position = "dodge"))
k1_df %>%
group_by(treat) %>%
summarise(VidNum = mean(vid.num)) %>%
ggplot(aes(x = treat, y = VidNum)) + geom_col(position = "dodge")
k1_df %>%
group_by(treat) %>%
summarise(VidNum = mean(vid.num)) %>%
ggplot(aes(x = treat, y = VidNum)) + geom_col(position = "dodge") + ylim(0.8,1.6)
k1_df %>%
group_by(treat) %>%
summarise(VidNum = mean(vid.num)) %>%
ggplot(aes(x = treat, y = VidNum)) + geom_col(position = "dodge")
k1_df %>%
group_by(treat) %>%
summarise(VidNum = mean(vid.num)) %>%
ggplot(aes(x = treat, y = VidNum)) + geom_col(position = "dodge") + coord_cartesian(ylim=c(0.8,1.6))
k1_df %>%
group_by(treat) %>%
summarise(VidNum = mean(vid.num)) %>%
ggplot(aes(x = treat, y = VidNum)) + geom_col(position = "dodge") + coord_cartesian(ylim=c(0.8,1.8))
k1_df %>%
group_by(treat) %>%
summarise(VidNum = mean(vid.num)) %>%
ggplot(aes(x = treat, y = VidNum)) + geom_col(position = "dodge") + coord_cartesian(ylim=c(0.8,2))
k1_df %>%
group_by(treat) %>%
summarise(VidNum = mean(vid.num)) %>%
ggplot(aes(x = treat, y = VidNum)) + geom_col(position = "dodge") + coord_cartesian(ylim=c(0.8,1.6))
k1_df %>%
group_by(treat) %>%
summarise(VidNum = mean(vid.num)) %>%
ggplot(aes(x = treat, y = VidNum)) + geom_col(position = "dodge") + coord_cartesian(ylim=c(0.9,1.6))
k1_df %>%
group_by(treat) %>%
summarise(VidNum = mean(vid.num)) %>%
ggplot(aes(x = treat, y = VidNum)) + geom_col(position = "dodge") + coord_cartesian(ylim=c(1,1.6))
k1_df_modified <- k1_df |> group_by(treat) %>%
summarise(VidNum = mean(vid.num), .groups = "keep") %>%
mutate(SEM = std.err(VidNum))
k1_df_modified <- k1_df |> group_by(treat) %>%
summarise(VidNum = mean(vid.num), .groups = "keep") %>%
mutate(SEM = std.err(k1_df$vid.num))
std.err <- function(x) sd(x)/sqrt(length(x))
k1_df_modified <- k1_df |> group_by(treat) %>%
summarise(VidNum = mean(vid.num), .groups = "keep") %>%
mutate(SEM = std.err(k1_df$vid.num))
ggplot(k1_df_modified, aes(x = treat, y = VidNum)) + geom_col(position = "dodge") + coord_cartesian(ylim=c(1,1.6))
ggplot(k1_df_modified, aes(x = treat, y = VidNum)) + geom_col(position = "dodge") + coord_cartesian(ylim=c(1,1.6)) + geom_errorbar()
ggplot(k1_df_modified, aes(x = treat, y = VidNum)) + geom_col(position = "dodge") + coord_cartesian(ylim=c(1,1.6)) + geom_errorbar(aes(ymin= VidNum - SEM, ymax = VidNum + SEM), position="dodge")
k1_df_modified <- k1_df |> group_by(treat) %>%
summarise(VidNum = mean(vid.num), .groups = "keep") %>%
mutate(SD = sd(k1_df$vid.num))
ggplot(k1_df_modified, aes(x = treat, y = VidNum)) + geom_col(position = "dodge") + coord_cartesian(ylim=c(1,1.6)) + geom_errorbar(aes(ymin= VidNum - 2*SD, ymax = VidNum + 2*SD), position="dodge")
k1_df %>%
group_by(treat) %>%
summarise(mean_vids = mean(vid.num),
se_vids = sd(vid.num) / sqrt(n()),
n = n()) %>%
ggplot(aes(x = treat, y = mean_vids)) +
geom_pointrange(aes(ymin = mean_vids - se_vids, ymax = mean_vids + se_vids))
k1_df %>%
group_by(treat) %>%
summarise(mean_sel = mean(sel.score.avg),
se_sel = sd(sel.score.avg) / sqrt(n()),
n = n()) %>%
ggplot(aes(x = treat, y = mean_sel)) +
geom_pointrange(aes(ymin = mean_sel - se_sel, ymax = mean_sel + se_sel))
k1_df %>%
group_by(treat) %>%
summarise(mean_vids = mean(vid.num),
se_vids = sd(vid.num) / sqrt(n()),
n = n()) %>%
ggplot(aes(x = treat, y = mean_vids)) +
geom_pointrange(aes(ymin = mean_vids - se_vids * 1.96, ymax = mean_vids + se_vids * 1.96))
k1_df %>%
group_by(treat) %>%
summarise(mean_vids = mean(vid.num),
se_vids = sd(vid.num) / sqrt(n()), # standard error
n = n()) %>%
ggplot(aes(x = treat, y = mean_vids, col = treat)) +
geom_pointrange(aes(ymin = mean_vids - se_vids * 1.96, ymax = mean_vids + se_vids * 1.96)) # Multiplying by 1.96 to approximate 95% confindence interval
# Set working directory
setwd("/Users/bendix/Desktop/krauss2003_rescue")
library("tidyverse")
library("qualtRics")
library("plyr")
# Set working directory
setwd("/Users/bendix/Desktop/krauss2003_rescue")
getwd()
data <- read_survey("./data/prescreening.csv")
view(data)
tidy_data = data |>
select("Prolific ID question", Finished, MontyHallQuestion) |>
filter(MontyHallQuestion == "No")
tidy_data = data |>
select(Q8, Finished, MontyHallQuestion) |>
filter(MontyHallQuestion == "No")
view(tidy_data)
paste0(tidy_data$Q8, collapse=",")
library(tidyverse)
library(metafor)
library(here)
theme_set(theme_bw())
#devtools::install_github("langcog/metalabr")
library(metalabr)
install.packages(metalabr)
install.packages("metalabr")
#devtools::install_github("langcog/metalabr")
library(metalabr)
library("tidyverse")
library("qualtRics")
library("plyr")
# Set working directory
setwd("/Users/bendix/Desktop/krauss2003_rescue")
getwd()
data <- read_survey("./data/Krauss & Wang replication pre-survey_December 4, 2023_15.41.csv")
view(data)
tidy_data = data |>
select(Q8, Finished, MontyHallQuestion) |>
filter(MontyHallQuestion == "No")
view(tidy_data)
paste0(letters[1:5], collapse=",")
paste0(tidy_data$G8, collapse=",")
paste0(tidy_data$Q8, collapse=",")
library("tidyverse")
library("qualtRics")
library("plyr")
# Set working directory
setwd("/Users/bendix/Desktop/krauss2003_rescue")
getwd()
data <- read_survey("./data/data_nonanon.csv")
view(data)
tidy_data = data |>
select("Prolific ID question", ResponseId, Finished, MontyHallQuestion) |>
mutate(switch = case_when(switch == 'switch to door 2' | switch == 'switch to the last remaining door' ~ TRUE,
TRUE ~ FALSE)) |>
dplyr::rename(wins_cases_if_stays = Q7, wins_cases_if_switches = Q9, already_familiar = Q14, already_knew_answer = Q15, own_answer = Q43) |>
mutate(already_familiar = case_when(already_familiar == 'I was familiar with this game' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(already_knew_answer = case_when(already_knew_answer == 'I already knew what the correct answer should be' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(own_answer = case_when(own_answer == 'I arrived at the answer on my own' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(control = case_when(is.na(wins_cases_if_stays) ~ TRUE,
TRUE ~ FALSE))
tidy_data = data |>
select("Prolific ID question", ResponseId, Finished, "Duration (in seconds)", Q7, Q9, Q10, Q20, Q14, Q15, Q43) |>
unite(switch, c(Q10, Q20), na.rm = T) |>
mutate(switch = case_when(switch == 'switch to door 2' | switch == 'switch to the last remaining door' ~ TRUE,
TRUE ~ FALSE)) |>
dplyr::rename(wins_cases_if_stays = Q7, wins_cases_if_switches = Q9, already_familiar = Q14, already_knew_answer = Q15, own_answer = Q43) |>
mutate(already_familiar = case_when(already_familiar == 'I was familiar with this game' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(already_knew_answer = case_when(already_knew_answer == 'I already knew what the correct answer should be' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(own_answer = case_when(own_answer == 'I arrived at the answer on my own' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(control = case_when(is.na(wins_cases_if_stays) ~ TRUE,
TRUE ~ FALSE))
view(tidy_data)
tidy_data = data |>
select(ResponseId, Finished, "Duration (in seconds)", Q7, Q9, Q10, Q20, Q14, Q15, Q43) |>
unite(switch, c(Q10, Q20), na.rm = T) |>
mutate(switch = case_when(switch == 'switch to door 2' | switch == 'switch to the last remaining door' ~ TRUE,
TRUE ~ FALSE)) |>
dplyr::rename(wins_cases_if_stays = Q7, wins_cases_if_switches = Q9, already_familiar = Q14, already_knew_answer = Q15, own_answer = Q43) |>
mutate(already_familiar = case_when(already_familiar == 'I was familiar with this game' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(already_knew_answer = case_when(already_knew_answer == 'I already knew what the correct answer should be' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(own_answer = case_when(own_answer == 'I arrived at the answer on my own' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(control = case_when(is.na(wins_cases_if_stays) ~ TRUE,
TRUE ~ FALSE))
view(tidy_data)
write.csv(tidy_data, "./data/experiment.csv")
library("tidyverse")
library("qualtRics")
library("plyr")
library("dplyr")
# Set working directory
setwd("/Users/bendix/Desktop/krauss2003_rescue")
getwd()
### load data
data <- read_survey("./data/experiment.csv")
### load data
data <- read_csv("./data/experiment.csv")
### load data
data <- read_csv("../data/experiment.csv")
view(data)
### load data
data <- read_survey("./data/data_nonanon.csv")
### load data
data <- read_survey("../data/data_nonanon.csv")
tidy_data = data |>
select(ResponseId, Finished, "Duration (in seconds)", Q7, Q9, Q10, Q20, Q14, Q15, Q43) |>
unite(switch, c(Q10, Q20), na.rm = T) |>
mutate(switch = case_when(switch == 'switch to door 2' | switch == 'switch to the last remaining door' ~ TRUE,
TRUE ~ FALSE)) |>
dplyr::rename(wins_cases_if_stays = Q7, wins_cases_if_switches = Q9, already_familiar = Q14, already_knew_answer = Q15, own_answer = Q43) |>
mutate(already_familiar = case_when(already_familiar == 'I was familiar with this game' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(already_knew_answer = case_when(already_knew_answer == 'I already knew what the correct answer should be' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(own_answer = case_when(own_answer == 'I arrived at the answer on my own' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(control = case_when(is.na(wins_cases_if_stays) ~ TRUE,
TRUE ~ FALSE))
relevant_tidy_data = tidy_data |>
filter("Duration (in seconds)" >= 60) |>
filter(Finished == T) |>
filter(already_familiar == F) |>
filter(already_knew_answer == F) |>
filter(own_answer == T) |>
select(ResponseId, control, switch)
relevant_tidy_data = relevant_tidy_data |>
mutate(correct_justification = "")
write.csv(relevant_tidy_data, "../data/experiment_to_be_coded.csv")
relevant_tidy_data = relevant_tidy_data[order(relevant_tidy_data$switch, decreasing = TRUE)]
view(relevant_tidy_data)
relevant_tidy_data = relevant_tidy_data[order(relevant_tidy_data$switch)]
relevant_tidy_data = relevant_tidy_data[order(relevant_tidy_data$switch),]
view(relevant_tidy_data)
write.csv(relevant_tidy_data, "../data/experiment_to_be_coded.csv")
tidy_data = data |>
select(ResponseId, Finished, "Duration (in seconds)", Q7, Q9, Q10, Q20, Q14, Q15, Q43) |>
unite(switch, c(Q10, Q20), na.rm = T) |>
mutate(switch = case_when(switch == 'switch to door 2' | switch == 'switch to the last remaining door' ~ TRUE,
TRUE ~ FALSE)) |>
dplyr::rename(wins_cases_if_stays = Q7, wins_cases_if_switches = Q9, already_familiar = Q14, already_knew_answer = Q15, own_answer = Q43) |>
mutate(already_familiar = case_when(already_familiar == 'I was familiar with this game' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(already_knew_answer = case_when(already_knew_answer == 'I already knew what the correct answer should be' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(own_answer = case_when(own_answer == 'I arrived at the answer on my own' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(control = case_when(is.na(wins_cases_if_stays) ~ TRUE,
TRUE ~ FALSE))
view(tidy_data)
relevant_tidy_data <- read_csv("../data/pilotB_coded.csv")
table <- with(
relevant_tidy_data,
table(correct_justification, control))
table
relevant_tidy_data <- read_csv("../data/experiment_coded.csv")
table <- with(
relevant_tidy_data,
table(correct_justification, control))
table
proportions = data.frame(Condition=c("Control","Experimental"),
Proportion=c((table[2, 2]/
(table[2, 2] + table[1, 2])), # the first proportion is that of correct justifications given in control condition
(table[2,1]/
(table[2, 1] + table[1, 1])))) # the second proportion is that of correct justifications given in experimental condition
proportions
view(proportions)
table <- with(
relevant_tidy_data,
table(switch, control))
table
proportions = data.frame(Condition=c("Control","Experimental"),
Proportion=c((table[2, 2]/
(table[2, 2] + table[1, 2])), # the first proportion is that of correct justifications given in control condition
(table[2,1]/
(table[2, 1] + table[1, 1])))) # the second proportion is that of correct justifications given in experimental condition
view(proportions)
table <- with(
relevant_tidy_data,
table(correct_justification, control))
table
proportions = data.frame(Condition=c("Control","Experimental"),
Proportion=c((table[2, 2]/
(table[2, 2] + table[1, 2])), # the first proportion is that of correct justifications given in control condition
(table[2,1]/
(table[2, 1] + table[1, 1])))) # the second proportion is that of correct justifications given in experimental condition
view(proportions)
library("pwr")
h <- ES.h(
proportions$Proportion[1], # the first proportion is that of correct justifications given in control condition
proportions$Proportion[2] # the second proportion is that of correct justifications given in experimental condition
)
h
h <- ES.h(
proportions$Proportion[2], # the second proportion is that of correct justifications given in experimental condition
proportions$Proportion[1] # the first proportion is that of correct justifications given in control condition
)
h
fisher_exact_test <- fisher.test(as.matrix(table))
fisher_exact_test
library(ggplot2)
plot <- ggplot(data=proportions, aes(x=Condition, y=(Proportion)*100)) +
geom_bar(stat="identity") +
scale_x_discrete(breaks=c("Control", "Experimental"),
labels=c("Control", "Experimental")) + ylim(0, 100) +
labs(title = "Pilot B results", x = "Condition", y = "Percentage correct (%)")
plot
plot <- ggplot(data=proportions, aes(x=Condition, y=(Proportion)*100)) +
geom_bar(stat="identity") +
scale_x_discrete(breaks=c("Control", "Experimental"),
labels=c("Control", "Experimental")) + ylim(0, 100) +
labs(title = "Replication results", x = "Condition", y = "Percentage correct (%)")
plot
proportions_original_study = data.frame(Condition=c("Control","Experimental"),
Proportion=c(.3, .38))
plot_original_study <- ggplot(data=proportions_original_study, aes(x=Condition, y=(Proportion)*100)) +
geom_bar(stat="identity") +
scale_x_discrete(breaks=c("Control","Experimental"),
labels=c("Control", "Experimental")) + ylim(0, 100) +
labs(title = "Original study results", x = "Condition", y = "Percentage correct (%)")
plot_original_study
plot
proportions_original_study = data.frame(Condition=c("Control","Experimental"),
Proportion=c(.3, .38))
plot_original_study <- ggplot(data=proportions_original_study, aes(x=Condition, y=(Proportion)*100)) +
geom_bar(stat="identity") +
scale_x_discrete(breaks=c("Control","Experimental"),
labels=c("Control", "Experimental")) + ylim(0, 100) +
labs(title = "Original study results", x = "Condition", y = "Percentage correct (%)")
plot_original_study
proportions_original_study = data.frame(Condition=c("Control","Experimental"),
Proportion=c(.03, .38))
plot_original_study <- ggplot(data=proportions_original_study, aes(x=Condition, y=(Proportion)*100)) +
geom_bar(stat="identity") +
scale_x_discrete(breaks=c("Control","Experimental"),
labels=c("Control", "Experimental")) + ylim(0, 100) +
labs(title = "Original study results", x = "Condition", y = "Percentage correct (%)")
plot_original_study
plot
plot_original_study
plot
table_switch <- with(
relevant_tidy_data,
table(switch, control))
chisq_test <- chisq.test(table_switch)
chisq_test
table_switch
# after coding answers, load file
relevant_tidy_data <- read_csv("../data/experiment_coded.csv")
# generate contingency table that displays how many participants in the control and experimental condition provided a correct justification
table <- with(
relevant_tidy_data,
table(correct_justification, control))
table
proportions = data.frame(Condition=c("Control","Experimental"),
Proportion=c((table[2, 2]/
(table[2, 2] + table[1, 2])), # the first proportion is that of correct justifications given in control condition
(table[2,1]/
(table[2, 1] + table[1, 1])))) # the second proportion is that of correct justifications given in experimental condition
view(proportions)
# perform Cohen's h test
library("pwr")
h <- ES.h(
proportions$Proportion[2], # the first proportion is that of correct justifications given in experimental condition
proportions$Proportion[1] # the second proportion is that of correct justifications given in control condition
)
h
# perform Fisher's exact test
fisher_exact_test <- fisher.test(as.matrix(table))
fisher_exact_test
# generate contingency table that displays how many participants in the control and experimental condition indicated that the contestant should switch (i.e., gave a correct answer)
table_switch <- with(
relevant_tidy_data,
table(switch, control))
table_switch
# Chi squared test for rate of switch choices
chisq_test <- chisq.test(table_switch)
chisq_test
# Plots of results
library(ggplot2)
# Plot from replication study
plot <- ggplot(data=proportions, aes(x=Condition, y=(Proportion)*100)) +
geom_bar(stat="identity") +
scale_x_discrete(breaks=c("Control", "Experimental"),
labels=c("Control", "Experimental")) + ylim(0, 100) +
labs(title = "Replication results", x = "Condition", y = "Percentage correct (%)")
plot
# Plot from the original study
proportions_original_study = data.frame(Condition=c("Control","Experimental"),
Proportion=c(.03, .38))
plot_original_study <- ggplot(data=proportions_original_study, aes(x=Condition, y=(Proportion)*100)) +
geom_bar(stat="identity") +
scale_x_discrete(breaks=c("Control","Experimental"),
labels=c("Control", "Experimental")) + ylim(0, 100) +
labs(title = "Original study results", x = "Condition", y = "Percentage correct (%)")
plot_original_study
# Set working directory
setwd("/Users/bendix/Desktop/krauss2003_rescue")
getwd()
### load data
data <- read_survey("../data/data_nonanon.csv")
tidy_data = data |>
select(ResponseId, Finished, "Duration (in seconds)", Q7, Q9, Q10, Q20, Q14, Q15, Q43) |>
unite(switch, c(Q10, Q20), na.rm = T) |>
mutate(switch = case_when(switch == 'switch to door 2' | switch == 'switch to the last remaining door' ~ TRUE,
TRUE ~ FALSE)) |>
dplyr::rename(wins_cases_if_stays = Q7, wins_cases_if_switches = Q9, already_familiar = Q14, already_knew_answer = Q15, own_answer = Q43) |>
mutate(already_familiar = case_when(already_familiar == 'I was familiar with this game' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(already_knew_answer = case_when(already_knew_answer == 'I already knew what the correct answer should be' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(own_answer = case_when(own_answer == 'I arrived at the answer on my own' ~ TRUE,
TRUE ~ FALSE)) |>
mutate(control = case_when(is.na(wins_cases_if_stays) ~ TRUE,
TRUE ~ FALSE))
relevant_tidy_data = tidy_data |>
filter("Duration (in seconds)" >= 60) |>
filter(Finished == T) |>
filter(already_familiar == F) |>
filter(already_knew_answer == F) |>
filter(own_answer == T) |>
select(ResponseId, control, switch)
relevant_tidy_data = relevant_tidy_data |>
mutate(correct_justification = "")
relevant_tidy_data = relevant_tidy_data[order(relevant_tidy_data$switch),]