-
Notifications
You must be signed in to change notification settings - Fork 0
/
Study1_Testing_the_Optimal_Policy_by_Preference.R
82 lines (71 loc) · 3.88 KB
/
Study1_Testing_the_Optimal_Policy_by_Preference.R
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
############################################
# Testing the Optimal Policy by Preference #
############################################
# Import Libraries
library("tidyverse")
library('lmerTest')
# Import data
Testing_the_Optimal_Policy_by_Preference <- as_tibble(read.csv("Study1_Testing_the_Optimal_Policy_by_Preference.csv"))
# Preview data
head(Testing_the_Optimal_Policy_by_Preference)
# data dictionary:
## "Participant" = participant number
## "Function" = Function number (range 1-4; refer to payoff function figure; function 5/6 omitted for this analysis (see details in paper))
## "Trial" = trial number (range: 11-150; only includes trials which participant had control of policies decisions)
## "Optimal_Policy_Selected" = Notes whether optimal policy (i.e., the policy choice that yields maximum output over time; 1=yes, 0=no)
## "Ambiguity" = Notes whether function ambiguity type (low or high)
## "Congruence" = Notes whether optimal policy choice was also participants preferred policy (1=yes; 0=no)
# Transform Predictor variables to use 'effects coding'
Testing_the_Optimal_Policy_by_Preference$Ambiguity_Coded <- ifelse(Testing_the_Optimal_Policy_by_Preference$Ambiguity=="Low", .5, -.5)
Testing_the_Optimal_Policy_by_Preference$Congruence_Coded <- ifelse(Testing_the_Optimal_Policy_by_Preference$Congruence=="1", .5, -.5)
# aggregate data by ambiguity and congruence
Testing_the_Optimal_Policy_by_Preference_2 <- Testing_the_Optimal_Policy_by_Preference %>%
group_by(Participant, Ambiguity_Coded, Congruence_Coded) %>%
summarise(Optimal_Policy_Selected_Percent=mean(Optimal_Policy_Selected),
n=n())
# maximal model does not converge:
# model_1 <- lmer(mean_OP_Coded ~ Congruence2*Ambiguity2 +
# (1+Congruence2*Ambiguity2|User),
# data=OP_dfz_simple_Study1)
# summary(model_1)
# Error: number of observations (=125) <= number of random effects (=164) for term (1 + Congruence2 * Ambiguity2 | User); the random-effects parameters and the residual variance (or scale parameter) are probably unidentifiable
# model
model_2 <- lmer(Optimal_Policy_Selected_Percent ~ Congruence_Coded*Ambiguity_Coded +
(1+Congruence_Coded*Ambiguity_Coded||Participant),
data=Testing_the_Optimal_Policy_by_Preference_2)
summary(model_2)
# output:
# Linear mixed model fit by REML. t-tests use Satterthwaite's method ['lmerModLmerTest']
# Formula: Optimal_Policy_Selected_Percent ~ Congruence_Coded * Ambiguity_Coded +
# (1 + Congruence_Coded * Ambiguity_Coded || Participant)
# Data: Testing_the_Optimal_Policy_by_Preference_2
#
# REML criterion at convergence: 67.6
#
# Scaled residuals:
# Min 1Q Median 3Q Max
# -1.64612 -0.48544 0.07728 0.58592 2.31899
#
# Random effects:
# Groups Name Variance Std.Dev.
# Participant (Intercept) 0.001066 0.03264
# Participant.1 Congruence_Coded 0.058547 0.24196
# Participant.2 Ambiguity_Coded 0.077886 0.27908
# Participant.3 Congruence_Coded:Ambiguity_Coded 0.049408 0.22228
# Residual 0.056910 0.23856
# Number of obs: 125, groups: Participant, 41
#
# Fixed effects:
# Estimate Std. Error df t value Pr(>|t|)
# (Intercept) 0.52922 0.02330 41.28756 22.709 < 2e-16 ***
# Congruence_Coded 0.37737 0.05910 38.17932 6.386 1.65e-07 ***
# Ambiguity_Coded 0.26471 0.06303 38.13140 4.200 0.000155 ***
# Congruence_Coded:Ambiguity_Coded -0.06686 0.09749 34.85804 -0.686 0.497404
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
#
# Correlation of Fixed Effects:
# (Intr) Cngr_C Ambg_C
# Congrnc_Cdd 0.055
# Ambigty_Cdd 0.052 0.001
# Cngrn_C:A_C -0.006 0.053 0.050