Uploading libraries
library (pacman)
p_load (tidyverse, glue, kableExtra)
Reading data
fn<- 'umbrella_2023-10-18.csv'
df<- read_csv (fn)
Rows: 1572 Columns: 86
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr (38): participant.code, participant.label, participant._current_app_nam...
dbl (34): participant.id_in_session, participant._is_bot, participant._inde...
lgl (13): participant.mturk_worker_id, participant.mturk_assignment_id, pla...
dttm (1): participant.time_started
ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Cleaning data
We get rid of all demo sessions, all participants who do not have labels (thus they are not prolific users, which means I just tested them myself) and who did not complete the study, and we also get rid of one person who managed to participate twice
sneaky_guy <- '63d196c147d1f420690e5b87'
df %>%
rename_with (~ gsub ("^player \\ ." , "" , .), starts_with ("player." )) %>%
filter (session.is_demo== 0 ,
! is.na (participant.label),
participant._index_in_pages== 32 ,
participant.label!= sneaky_guy) %>%
rename (label= participant.label, round_number= subsession.round_number)->
df
Observations per treatment:
df %>% group_by (label, glob_treatment) %>%
tally %>% group_by (glob_treatment) %>% tally %>% kbl () %>% kableExtra:: kable_classic_2 ()
glob_treatment
n
T1-CC
71
T2-CR
72
T3-CA
71
T4-RA
70
T5-AR
69
T6-RC
69
T7-AC
70
Means across rounds for main DVs.
We have three main DVs for three different risk measures:
mpl_switching_row
scl_lottery_choice
cem_switching_row
maindvs<- c ('mpl_switching_row' , 'scl_lottery_choice' , "cem_switching_row" )
long_df <- df %>% select (label,
round_number, glob_treatment, treatment,
all_of (maindvs)
) %>%
pivot_longer (cols = all_of (maindvs),
names_to = "variable" ,
values_to = "value" )
Means per round
long_df %>% group_by (variable,round_number) %>% summarise (mean (value))
`summarise()` has grouped output by 'variable'. You can override using the
`.groups` argument.
# A tibble: 6 × 3
# Groups: variable [3]
variable round_number `mean(value)`
<chr> <dbl> <dbl>
1 cem_switching_row 1 4.72
2 cem_switching_row 2 4.80
3 mpl_switching_row 1 7.35
4 mpl_switching_row 2 7.16
5 scl_lottery_choice 1 3.02
6 scl_lottery_choice 2 3.09
Differences
long_df %>% group_by (variable,round_number) %>% summarise (m= mean (value)) %>%
pivot_wider (names_from= round_number, values_from= m, names_prefix= 'round_' ) %>%
mutate (diff= round_2- round_1)
`summarise()` has grouped output by 'variable'. You can override using the
`.groups` argument.
# A tibble: 3 × 4
# Groups: variable [3]
variable round_1 round_2 diff
<chr> <dbl> <dbl> <dbl>
1 cem_switching_row 4.72 4.80 0.0833
2 mpl_switching_row 7.35 7.16 -0.189
3 scl_lottery_choice 3.02 3.09 0.0752
Means per treatment
long_df %>% group_by (variable,treatment) %>% summarise (m= mean (value)) %>%
pivot_wider (names_from= treatment, values_from= m)
`summarise()` has grouped output by 'variable'. You can override using the
`.groups` argument.
# A tibble: 3 × 4
# Groups: variable [3]
variable ambiguity control risk
<chr> <dbl> <dbl> <dbl>
1 cem_switching_row 4.79 4.68 4.85
2 mpl_switching_row 7.28 7.23 7.27
3 scl_lottery_choice 3 3.04 3.14
Means per individual treatment (chain of subtreatments)
long_df %>% group_by (glob_treatment, treatment,variable) %>% summarise (m= mean (value)) %>%
pivot_wider (names_from= variable, values_from = m) %>% kbl %>% kable_classic_2
`summarise()` has grouped output by 'glob_treatment', 'treatment'. You can
override using the `.groups` argument.
glob_treatment
treatment
cem_switching_row
mpl_switching_row
scl_lottery_choice
T1-CC
control
4.443662
7.788732
2.936620
T2-CR
control
4.750000
7.500000
3.180556
T2-CR
risk
4.736111
7.319444
3.430556
T3-CA
ambiguity
5.140845
7.211268
3.028169
T3-CA
control
4.901408
7.112676
2.971831
T4-RA
ambiguity
4.700000
7.214286
3.057143
T4-RA
risk
4.828571
7.528571
3.114286
T5-AR
ambiguity
5.159420
7.507246
2.826087
T5-AR
risk
5.043478
7.434783
2.971014
T6-RC
control
4.652174
6.681159
3.072464
T6-RC
risk
4.811594
6.782609
3.043478
T7-AC
ambiguity
4.157143
7.171429
3.085714
T7-AC
control
4.900000
6.471429
3.114286
Individual player’s differences (changes from round 1 to round 2)
long_df %>% group_by (variable, label,round_number, treatment) %>%
summarize (dv= mean (value, na.rm= T)) %>%
ungroup () %>%
pivot_wider ( names_from= round_number, values_from= c (dv, treatment) ) %>%
mutate (diff= dv_2- dv_1, globtreat= glue ('{treatment_1}-{treatment_2}' )) %>%
group_by (variable,globtreat) %>%
summarise (mean_diff= mean (diff), sd_diff= sd (diff), n= n ()) %>%
rowwise () %>%
mutate (
t_value = (mean_diff - 0 ) / (sd_diff / sqrt (n)),
degrees_of_freedom = n - 1 ,
p_value = 2 * pt (- abs (t_value), degrees_of_freedom)
) -> for_split
`summarise()` has grouped output by 'variable', 'label', 'round_number'. You
can override using the `.groups` argument.
`summarise()` has grouped output by 'variable'. You can override using the
`.groups` argument.
list_of_dfs <- split (for_split, for_split$ variable)
for (variable in names (list_of_dfs)) {
cat (paste0 ("## Table for variable: " , variable, " \n " ))
list_of_dfs[[variable]] %>% ungroup () %>%
select (- variable,- t_value, - degrees_of_freedom) %>%
kbl () %>% kable_classic_2 () %>% cat ()
cat (" \n\n " )
}
Table for variable: cem_switching_row
globtreat
mean_diff
sd_diff
n
p_value
ambiguity-control
0.7428571
2.061980
70
0.0036026
ambiguity-risk
-0.1159420
1.649744
69
0.5613000
control-ambiguity
0.2394366
1.634143
71
0.2211042
control-control
0.0140845
1.816535
71
0.9480958
control-risk
-0.0138889
1.834667
72
0.9489630
risk-ambiguity
-0.1285714
2.105352
70
0.6110249
risk-control
-0.1594203
2.506598
69
0.5990088
Table for variable: mpl_switching_row
globtreat
mean_diff
sd_diff
n
p_value
ambiguity-control
-0.7000000
2.994439
70
0.0545349
ambiguity-risk
-0.0724638
2.024256
69
0.7670995
control-ambiguity
0.0985915
2.757613
71
0.7641124
control-control
-0.0563380
2.585052
71
0.8548287
control-risk
-0.1805556
2.309359
72
0.5092128
risk-ambiguity
-0.3142857
2.350102
70
0.2670678
risk-control
-0.1014493
3.417709
69
0.8059846
Table for variable: scl_lottery_choice
globtreat
mean_diff
sd_diff
n
p_value
ambiguity-control
0.0285714
1.849179
70
0.8975191
ambiguity-risk
0.1449275
1.320376
69
0.3651191
control-ambiguity
0.0563380
1.452951
71
0.7448522
control-control
0.0704225
1.345086
71
0.6604606
control-risk
0.2500000
1.758280
72
0.2316392
risk-ambiguity
-0.0571429
1.631979
70
0.7704380
risk-control
0.0289855
1.562154
69
0.8779653