%%R
sessionInfo()
R version 3.2.3 (2015-12-10) Platform: x86_64-apple-darwin13.4.0 (64-bit) Running under: OS X 10.11.5 (El Capitan) locale: [1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8 attached base packages: [1] tools stats graphics grDevices utils datasets methods [8] base other attached packages: [1] pbkrtest_0.4-2 mlogit_0.2-4 maxLik_1.3-4 miscTools_0.6-16 [5] Formula_1.2-1 MASS_7.3-45 optimx_2013.8.7 gdata_2.17.0 [9] car_2.1-0 lme4_1.1-12 Matrix_1.2-3 loaded via a namespace (and not attached): [1] Rcpp_0.12.1 nloptr_1.0.4 optextras_2013-10.28 [4] statmod_1.4.22 svUnit_0.7-12 nlme_3.1-124 [7] lattice_0.20-33 ucminf_1.1-3 mgcv_1.8-9 [10] parallel_3.2.3 SparseM_1.7 Rcgmin_2013-2.21 [13] BB_2014.10-1 gtools_3.5.0 MatrixModels_0.4-1 [16] lmtest_0.9-34 grid_3.2.3 nnet_7.3-11 [19] setRNG_2013.9-1 dfoptim_2011.8-1 Rvmmin_2013-11.12 [22] minqa_1.2.4 splines_3.2.3 numDeriv_2014.2-1 [25] quantreg_5.19 quadprog_1.5-5 sandwich_2.3-4 [28] zoo_1.7-12
%%R
main_choice_model_exp1 = glmer(Chose_right ~ zDV + zConf + zSV + zDDT + zDV:zConf +
zDV:zSV + (zDV + zConf + zDDT + zDV:zConf +
zDV:zSV| Participant), data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
fix_1a <- fixef(main_choice_model_exp1)
fix_se_1a <- sqrt(diag(vcov(main_choice_model_exp1)))
names_1a <- names(fix_1a)
summary(main_choice_model_exp1)
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod] Family: binomial ( logit ) Formula: Chose_right ~ zDV + zConf + zSV + zDDT + zDV:zConf + zDV:zSV + (zDV + zConf + zDDT + zDV:zConf + zDV:zSV | Participant) Data: data_exp1 Control: glmerControl(optimizer = "optimx", optCtrl = list(method = "nlminb")) AIC BIC logLik deviance df.resid 3890.5 4081.2 -1917.2 3834.5 6692 Scaled residuals: Min 1Q Median 3Q Max -23.8380 -0.2312 -0.0003 0.2343 10.8933 Random effects: Groups Name Variance Std.Dev. Corr Participant (Intercept) 0.004379 0.06618 zDV 3.075341 1.75366 -0.45 zConf 0.004543 0.06740 -0.60 -0.15 zDDT 0.809031 0.89946 0.18 -0.31 -0.27 zDV:zConf 0.356179 0.59681 0.16 0.73 -0.78 -0.05 zDV:zSV 0.436688 0.66082 0.53 -0.07 0.11 -0.10 -0.10 Number of obs: 6720, groups: Participant, 28 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) -0.085018 0.052716 -1.613 0.10680 zDV 4.216931 0.368040 11.458 < 2e-16 *** zConf -0.070665 0.046169 -1.531 0.12588 zSV -0.006134 0.039067 -0.157 0.87525 zDDT 0.881635 0.178172 4.948 7.49e-07 *** zDV:zConf 1.241375 0.168060 7.386 1.51e-13 *** zDV:zSV -0.516571 0.167386 -3.086 0.00203 ** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) zDV zConf zSV zDDT zDV:zC zDV -0.116 zConf 0.421 -0.051 zSV -0.074 -0.001 -0.252 zDDT 0.043 -0.262 -0.075 0.005 zDV:zConf 0.006 0.625 -0.176 0.012 -0.037 zDV:zSV 0.101 -0.104 0.034 -0.022 -0.078 -0.096 convergence code: 0 Parameters or bounds appear to have different scalings. This can cause poor performance in optimization. It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.
%%R
main_choice_model_exp2 = glmer(Chose_Item_1 ~ zItem1_DV + zConf + zSV + zItem1_DDT +
zItem1_DV:zConf + zItem1_DV:zSV + (zItem1_DV +
zConf + zSV + zItem1_DDT + zItem1_DV:zConf +
zItem1_DV:zSV| Participant), data=data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
fix_1b <- fixef(main_choice_model_exp2)
fix_se_1b <- sqrt(diag(vcov(main_choice_model_exp2)))
names_1b <- names(fix_1b)
summary(main_choice_model_exp2)
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod] Family: binomial ( logit ) Formula: Chose_Item_1 ~ zItem1_DV + zConf + zSV + zItem1_DDT + zItem1_DV:zConf + zItem1_DV:zSV + (zItem1_DV + zConf + zSV + zItem1_DDT + zItem1_DV:zConf + zItem1_DV:zSV | Participant) Data: data_exp2 Control: glmerControl(optimizer = "optimx", optCtrl = list(method = "nlminb")) AIC BIC logLik deviance df.resid 2741.9 2956.9 -1335.9 2671.9 3408 Scaled residuals: Min 1Q Median 3Q Max -21.538 -0.434 -0.172 0.344 140.287 Random effects: Groups Name Variance Std.Dev. Corr Participant (Intercept) 0.058627 0.2421 zItem1_DV 0.844981 0.9192 -0.71 zConf 0.019078 0.1381 0.36 -0.58 zSV 0.007124 0.0844 0.91 -0.85 0.22 zItem1_DDT 0.547287 0.7398 -0.33 -0.40 0.50 -0.12 zItem1_DV:zConf 0.042511 0.2062 -0.78 0.58 -0.80 -0.54 0.08 zItem1_DV:zSV 0.025297 0.1591 0.08 -0.75 0.40 0.39 0.85 -0.03 Number of obs: 3443, groups: Participant, 24 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) -1.183972 0.077482 -15.281 < 2e-16 *** zItem1_DV 1.331567 0.206608 6.445 1.16e-10 *** zConf -0.004155 0.066824 -0.062 0.9504 zSV -0.012950 0.060289 -0.215 0.8299 zItem1_DDT 1.685743 0.171824 9.811 < 2e-16 *** zItem1_DV:zConf 0.521309 0.090217 5.778 7.54e-09 *** zItem1_DV:zSV -0.239900 0.084442 -2.841 0.0045 ** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) zIt1_DV zConf zSV zI1_DD zI1_DV:C zItem1_DV -0.526 zConf 0.195 -0.264 zSV 0.223 -0.234 -0.188 zItem1_DDT -0.298 -0.320 0.241 -0.040 zItm1_DV:zC -0.329 0.314 -0.413 -0.034 0.049 zItm1_DV:SV 0.014 -0.375 0.125 -0.279 0.285 -0.097 convergence code: 0 Parameters or bounds appear to have different scalings. This can cause poor performance in optimization. It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.
logisticplot_all('Conf_Dich', 'High Confidence', 'Low Confidence', data=data_exp1, xaxis='zDV', yaxis='Chose_right', ylab='P(Right Item)', xlab='Difference in Value (DV)',
modhighcol='#000000', modlowcol='#AAAAAA', title='empty', parvar='Participant')
plt.tight_layout()
#plt.savefig('figures/Conf_Log_Exp1.png', dpi=600)
%R -o fix_1a -o fix_se_1a -o names_1a
choice_table_exp1 = regtable(fix_1a, fix_se_1a, names_1a)
choice_table_exp1
cols = ['(Intercept)', 'zDV', 'zConf', 'zSV', 'zDV:zConf', 'zDV:zSV', 'zDDT']
choice_table_exp1 = choice_table_exp1[cols]
choice_table_exp1.columns = ['Intercept', 'DV', 'Confidence',
'SV', 'DV x Confidence', 'DV x SV', 'DDT']
Coefpresplot(choice_table_exp1, title='', ticklabsize=16, size='narrow',
ylimits=(-1.5, 5.5), ymultiple=1, n_ET_predictors=1)
[i.set_color('#03719c') for i in plt.gca().get_xticklabels()[5:]]
#plt.savefig('figures/exp1_choice.png', bbox_inches='tight', dpi=600)
[None]
logisticplot_all('Conf_Dich', 'High Confidence', 'Low Confidence', data=data_exp2, xaxis='zItem1_DV', yaxis='Chose_Item_1', ylab='P(Reference Item)', xlab='Difference in Value (DV)',
modhighcol='#000000', modlowcol='#AAAAAA', title='empty', parvar='Participant')
plt.tight_layout()
#plt.savefig('../figures/Conf_Log_Exp2.png', dpi=600)
%R -o fix_1b -o fix_se_1b -o names_1b
choice_table_exp2 = regtable(fix_1b, fix_se_1b, names_1b)
choice_table_exp2
cols = ['(Intercept)', 'zItem1_DV', 'zConf', 'zSV', 'zItem1_DV:zConf',
'zItem1_DV:zSV', 'zItem1_DDT']
choice_table_exp2 = choice_table_exp2[cols]
choice_table_exp2.columns = ['Intercept', 'DV', 'Confidence',
'SV', 'DV x Confidence', 'DV x SV', 'DDT']
Coefpresplot(choice_table_exp2, title='', ticklabsize=16, size='narrow',
ylimits=(-0.5, 2), ymultiple=0.5, n_ET_predictors=1)
[i.set_color('#03719c') for i in plt.gca().get_xticklabels()[5:]]
#plt.savefig('figures/exp1_choice.png', bbox_inches='tight', dpi=600)
[None]
%%R
## Running the hierarchical model in lmer
main_confidence_model_exp1 = lmer(zConf ~ 0 + zabsDV + zRT + zGSF
+ zSV + (0 + zabsDV + zRT + zGSF + zSV | Participant),
data=data_exp1, control=lmerControl(optimizer="optimx",
optCtrl=list(method="nlminb")))
## Estimating DFs and p-values
# get the coefficients for the best fitting model
coefs <- data.frame(coef(summary(main_confidence_model_exp1)))
# Use the Kenward-Roger approximation to get approximate degrees of freedom
df.KR <- get_ddf_Lb(main_confidence_model_exp1, fixef(main_confidence_model_exp1))
coefs$df.KR <-(rep(df.KR, each=4))
# Calculate confidence intervals from the estimates and the standard errors
coefs$semax <- coefs$Estimate + (coefs$Std..Error)
coefs$semin <- coefs$Estimate - (coefs$Std..Error)
# get p-values from the t-distribution using the t-values and approximated
# degrees of freedom
coefs$p.KR <- 2 * (1 - pt(abs(coefs$t.value), df.KR))
# use normal distribution to approximate p-value (tends to be anti-conservative with small sample sizes)
coefs$p.z <- 2 * (1 - pnorm(abs(coefs$t.value)))
%%R
summary(main_confidence_model_exp1)
Linear mixed model fit by REML ['lmerMod'] Formula: zConf ~ 0 + zabsDV + zRT + zGSF + zSV + (0 + zabsDV + zRT + zGSF + zSV | Participant) Data: data_exp1 Control: lmerControl(optimizer = "optimx", optCtrl = list(method = "nlminb")) REML criterion at convergence: 15419.7 Scaled residuals: Min 1Q Median 3Q Max -5.4875 -0.5466 0.1016 0.6605 4.2325 Random effects: Groups Name Variance Std.Dev. Corr Participant zabsDV 0.013737 0.11721 zRT 0.023195 0.15230 0.37 zGSF 0.001446 0.03802 0.87 -0.11 zSV 0.065648 0.25622 0.01 0.44 -0.35 Residual 0.562423 0.74995 Number of obs: 6720, groups: Participant, 28 Fixed effects: Estimate Std. Error t value zabsDV 0.32646 0.02444 13.358 zRT -0.31003 0.03108 -9.977 zGSF -0.05003 0.01371 -3.650 zSV 0.17505 0.04942 3.542 Correlation of Fixed Effects: zabsDV zRT zGSF zRT 0.343 zGSF 0.428 -0.237 zSV -0.009 0.398 -0.176
%R -o coefs
conf_table_exp1 = coefs
conf_table_exp1.columns = ['coefficient', 'se', 't', 'DF', 'CImax', 'CImin', 'p', 'p2']
conf_table_exp1 = conf_table_exp1.iloc[:, 0:-1].copy(); conf_table_exp1.loc[:, 'SEmax'] = conf_table_exp1['coefficient'] + conf_table_exp1['se']*2
conf_table_exp1.loc[:, 'SEmin'] = conf_table_exp1['coefficient'] - conf_table_exp1['se']*2
conf_table_exp1 = conf_table_exp1.transpose()
conf_table_exp1.columns = ['|DV|', 'RT', 'GSF', 'SV']
conf_table_exp1.loc['p'] = np.round(conf_table_exp1.loc['p'], 5)
conf_table_exp1 = conf_table_exp1[['|DV|', 'RT', 'SV', 'GSF']]
conf_table_exp1
|DV| | RT | SV | GSF | |
---|---|---|---|---|
coefficient | 0.174746 | -0.288588 | 0.198925 | -0.175526 |
se | 0.021582 | 0.038189 | 0.042379 | 0.019791 |
t | 8.096949 | -7.556827 | 4.693988 | -8.869160 |
DF | 22.928596 | 22.928596 | 22.928596 | 22.928596 |
CImax | 0.196328 | -0.250399 | 0.241304 | -0.155736 |
CImin | 0.153164 | -0.326777 | 0.156546 | -0.195317 |
p | 0.000000 | 0.000000 | 0.000100 | 0.000000 |
SEmax | 0.217909 | -0.212210 | 0.283682 | -0.135945 |
SEmin | 0.131583 | -0.364966 | 0.114168 | -0.215108 |
%%R
## Running the hierarchical model in lmer
main_confidence_model_exp2 = lmer(zConf ~ 0 + zAbsDV + zRT + zGSF
+ zSV + (0 + zAbsDV + zRT + zGSF + zSV | Participant),
data=data_exp2, control=lmerControl(optimizer="optimx",
optCtrl=list(method="nlminb")))
## Estimating DFs and p-values
# get the coefficients for the best fitting model
coefs <- data.frame(coef(summary(main_confidence_model_exp2)))
# Use the Kenward-Roger approximation to get approximate degrees of freedom
df.KR <- get_ddf_Lb(main_confidence_model_exp2, fixef(main_confidence_model_exp2))
coefs$df.KR <-(rep(df.KR, each=4))
# Calculate confidence intervals from the estimates and the standard errors
coefs$semax <- coefs$Estimate + (coefs$Std..Error)
coefs$semin <- coefs$Estimate - (coefs$Std..Error)
# get p-values from the t-distribution using the t-values and approximated
# degrees of freedom
coefs$p.KR <- 2 * (1 - pt(abs(coefs$t.value), df.KR))
# use normal distribution to approximate p-value (tends to be anti-conservative with small sample sizes)
coefs$p.z <- 2 * (1 - pnorm(abs(coefs$t.value)))
%%R
summary(main_confidence_model_exp2)
Linear mixed model fit by REML ['lmerMod'] Formula: zConf ~ 0 + zAbsDV + zRT + zGSF + zSV + (0 + zAbsDV + zRT + zGSF + zSV | Participant) Data: data_exp2 Control: lmerControl(optimizer = "optimx", optCtrl = list(method = "nlminb")) REML criterion at convergence: 8336.5 Scaled residuals: Min 1Q Median 3Q Max -4.1104 -0.6468 0.0477 0.6558 4.2440 Random effects: Groups Name Variance Std.Dev. Corr Participant zAbsDV 0.006177 0.07860 zRT 0.027200 0.16492 0.22 zGSF 0.001332 0.03649 0.38 0.61 zSV 0.038188 0.19542 0.56 0.52 0.97 Residual 0.635119 0.79694 Number of obs: 3443, groups: Participant, 24 Fixed effects: Estimate Std. Error t value zAbsDV 0.17475 0.02158 8.097 zRT -0.28859 0.03819 -7.557 zGSF -0.17553 0.01979 -8.869 zSV 0.19892 0.04238 4.694 Correlation of Fixed Effects: zAbsDV zRT zGSF zRT 0.162 zGSF 0.149 -0.074 zSV 0.424 0.418 0.389
%R -o coefs
conf_table_exp2 = coefs
conf_table_exp2.columns = ['coefficient', 'se', 't', 'DF', 'CImax', 'CImin', 'p', 'p2']
conf_table_exp2 = conf_table_exp2.iloc[:, 0:-1].copy(); conf_table_exp2.loc[:, 'SEmax'] = conf_table_exp2['coefficient'] + conf_table_exp2['se']*2
conf_table_exp2.loc[:, 'SEmin'] = conf_table_exp2['coefficient'] - conf_table_exp2['se']*2
conf_table_exp2 = conf_table_exp2.transpose()
conf_table_exp2.columns = ['|DV|', 'RT', 'GSF', 'SV']
conf_table_exp2.loc['p'] = np.round(conf_table_exp2.loc['p'], 5)
conf_table_exp2 = conf_table_exp2[['|DV|', 'RT', 'SV', 'GSF']]
conf_table_exp2
|DV| | RT | SV | GSF | |
---|---|---|---|---|
coefficient | 0.174746 | -0.288588 | 0.198925 | -0.175526 |
se | 0.021582 | 0.038189 | 0.042379 | 0.019791 |
t | 8.096949 | -7.556827 | 4.693988 | -8.869160 |
DF | 22.928596 | 22.928596 | 22.928596 | 22.928596 |
CImax | 0.196328 | -0.250399 | 0.241304 | -0.155736 |
CImin | 0.153164 | -0.326777 | 0.156546 | -0.195317 |
p | 0.000000 | 0.000000 | 0.000100 | 0.000000 |
SEmax | 0.217909 | -0.212210 | 0.283682 | -0.135945 |
SEmin | 0.131583 | -0.364966 | 0.114168 | -0.215108 |
Coefpresplot(conf_table_exp1, title='', intercept=True, ticklabsize=16, size='narrow', n_ET_predictors=1)
[i.set_color('#03719c') for i in plt.gca().get_xticklabels()[3:]]
#plt.savefig('exp1_confidence.png', bbox_inches='tight', dpi=600)
# build the figure and specify that we want a 3d projection
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111, projection='3d')
# set background colour
plt.gca().patch.set_facecolor('white')
# set box colour
ax.w_xaxis.set_pane_color((0.7, 0.7, 0.7, 1.0))
ax.w_yaxis.set_pane_color((0.7, 0.7, 0.7, 1.0))
ax.w_zaxis.set_pane_color((0.7, 0.7, 0.7, 1.0))
# create the cordinate space for the x and y axis
X = np.arange(1, 6) # RT
Y = np.arange(1, 6) # DV
X, Y = np.meshgrid(X, Y)
# get the 3d landscape from the switch data
Z = Z_Switch_Heat_exp1
Gx, Gy = np.gradient(Z) # gradients with respect to x and y
G = (Gx**2+Gy**2)**.5 # gradient magnitude
N = G/G.max() # normalize 0..1
# paint the 3d landscape with the confidence data
surf = ax.plot_surface(
X, Y, Z, rstride=1, cstride=1,
facecolors=cm.GnBu(Z_Conf_Heat_exp1), # cm.GnBu sets the colour scheme
linewidth=0, antialiased=True, shade=False)
# Fiddle with the axes
ax.set(xticks=[1, 5], yticks=[1, 5], xticklabels=['Slow', 'Fast'], xlabel='Response Time', ylabel='|Difference in Value|',
yticklabels=['High', 'Low'], zticks=[0, 1], zlabel='Gaze Shift Frequency', zticklabels=['Low', 'High'],)
ax.yaxis.label.set_size(18); ax.tick_params(labelsize=16)
ax.xaxis.label.set_size(18); ax.xaxis.labelpad = 10; ax.yaxis.labelpad = 15
ax.zaxis.label.set_size(18); ax.zaxis.labelpad = 15; ax.tick_params(direction='out', pad=8)
#plt.savefig('figures/4d_plot_two_options.png', dpi=600)
Coefpresplot(conf_table_exp2, title='', intercept=True, ticklabsize=16, size='narrow', n_ET_predictors=1)
[i.set_color('#03719c') for i in plt.gca().get_xticklabels()[3:]]
#plt.savefig('exp2_confidence_no_intercept.png', bbox_inches='tight', dpi=600)
# build the figure and specify that we want a 3d projection
fig = plt.figure(figsize=(10, 8))
ax = fig.add_subplot(111, projection='3d')
# set background colour
plt.gca().patch.set_facecolor('white')
# set box colour
ax.w_xaxis.set_pane_color((0.7, 0.7, 0.7, 1.0))
ax.w_yaxis.set_pane_color((0.7, 0.7, 0.7, 1.0))
ax.w_zaxis.set_pane_color((0.7, 0.7, 0.7, 1.0))
# create the cordinate space for the x and y axis
X = np.arange(1, 6) # RT
Y = np.arange(1, 6) # DV
X, Y = np.meshgrid(X, Y)
# get the 3d landscape from the switch data
Z = Z_Switch_Heat_exp2
Gx, Gy = np.gradient(Z) # gradients with respect to x and y
G = (Gx**2+Gy**2)**.5 # gradient magnitude
N = G/G.max() # normalize 0..1
# paint the 3d landscape with the confidence data
surf = ax.plot_surface(
X, Y, Z, rstride=1, cstride=1,
facecolors=cm.GnBu(Z_Conf_Heat_exp2), # cm.GnBu sets the colour scheme
linewidth=0, antialiased=True, shade=False)
# Fiddle with the axes
ax.set(xticks=[1, 5], yticks=[1, 5], xticklabels=['Slow', 'Fast'], xlabel='Response Time', ylabel='|Difference in Value|',
yticklabels=['High', 'Low'], zticks=[0, 1], zlabel='Gaze Shift Frequency', zticklabels=['Low', 'High'],)
ax.yaxis.label.set_size(18); ax.tick_params(labelsize=16)
ax.xaxis.label.set_size(18); ax.xaxis.labelpad = 10; ax.yaxis.labelpad = 15
ax.zaxis.label.set_size(18); ax.zaxis.labelpad = 15; ax.tick_params(direction='out', pad=8)
#plt.savefig('figures/4d_plot_two_options.png', dpi=600)
%%R
print(round(cor(data_exp1$zGSF, data_exp1$zDDT), 2))
[1] -0.02
%%R
print(round(cor(data_exp2$zGSF, data_exp2$zItem1_DDT), 2))
[1] 0.04
%%R
main_CoM_model_exp1 = glmer(CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF +
zAbsDDT + (zAbsDV + zConf + zRT + zSV + zGSF +
zAbsDDT | Participant), data=CoM_data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
summary(main_CoM_model_exp1)
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod] Family: binomial ( logit ) Formula: CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT | Participant) Data: CoM_data_exp1 Control: glmerControl(optimizer = "optimx", optCtrl = list(method = "nlminb")) AIC BIC logLik deviance df.resid 1599.5 1813.7 -764.8 1529.5 3325 Scaled residuals: Min 1Q Median 3Q Max -1.4358 -0.2953 -0.1585 -0.0721 12.3658 Random effects: Groups Name Variance Std.Dev. Corr Participant (Intercept) 0.567129 0.75308 zAbsDV 0.302509 0.55001 0.63 zConf 0.020702 0.14388 -0.34 -0.47 zRT 0.278594 0.52782 -0.36 0.31 0.21 zSV 0.079923 0.28271 0.15 0.18 -0.15 -0.50 zGSF 0.108475 0.32935 0.66 -0.01 -0.20 -0.93 0.54 zAbsDDT 0.004972 0.07051 -0.19 -0.84 0.54 -0.64 0.14 0.48 Number of obs: 3360, groups: Participant, 28 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) -3.607640 0.211003 -17.098 < 2e-16 *** zAbsDV -1.277815 0.181621 -7.036 1.98e-12 *** zConf -0.596261 0.089040 -6.697 2.13e-11 *** zRT 0.260239 0.142904 1.821 0.06860 . zSV 0.267822 0.090349 2.964 0.00303 ** zGSF -0.099269 0.115235 -0.861 0.38899 zAbsDDT 0.008073 0.071138 0.113 0.90965 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) zAbsDV zConf zRT zSV zGSF zAbsDV 0.676 zConf 0.108 -0.183 zRT -0.236 0.121 0.189 zSV -0.031 0.012 -0.247 -0.248 zGSF 0.278 0.008 0.015 -0.777 0.172 zAbsDDT -0.029 -0.105 0.014 -0.491 0.020 0.326 convergence code: 0 Parameters or bounds appear to have different scalings. This can cause poor performance in optimization. It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.
%%R
fix_2a <- fixef(main_CoM_model_exp1)
fix_se_2a <- sqrt(diag(vcov(main_CoM_model_exp1)))
names_2a <- names(fix_2a)
%%R
main_CoM_model_exp2 = glmer(CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF +
zAbsDDT + (zAbsDV + zConf + zRT + zSV + zGSF +
zAbsDDT | Participant), data=CoM_data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
summary(main_CoM_model_exp2)
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod] Family: binomial ( logit ) Formula: CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT | Participant) Data: CoM_data_exp2 Control: glmerControl(optimizer = "optimx", optCtrl = list(method = "nlminb")) AIC BIC logLik deviance df.resid 1712.2 1913.0 -821.1 1642.2 2258 Scaled residuals: Min 1Q Median 3Q Max -1.5180 -0.4071 -0.2874 -0.1960 4.7618 Random effects: Groups Name Variance Std.Dev. Corr Participant (Intercept) 0.238322 0.48818 zAbsDV 0.058565 0.24200 0.08 zConf 0.018116 0.13460 0.36 0.22 zRT 0.046614 0.21590 -0.52 0.21 -0.31 zSV 0.049834 0.22323 0.24 0.72 -0.31 0.42 zGSF 0.004472 0.06687 0.83 -0.09 -0.22 -0.30 0.43 zAbsDDT 0.031756 0.17820 0.17 -0.20 0.89 -0.20 -0.61 -0.33 Number of obs: 2293, groups: Participant, 24 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) -2.27467 0.13218 -17.209 < 2e-16 *** zAbsDV -0.13701 0.09871 -1.388 0.165117 zConf -0.48462 0.08473 -5.719 1.07e-08 *** zRT 0.34499 0.09538 3.617 0.000298 *** zSV 0.15388 0.08531 1.804 0.071267 . zGSF 0.06135 0.08243 0.744 0.456724 zAbsDDT 0.02719 0.06892 0.394 0.693224 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) zAbsDV zConf zRT zSV zGSF zAbsDV 0.118 zConf 0.243 -0.055 zRT -0.326 0.057 0.161 zSV 0.084 0.363 -0.222 0.014 zGSF 0.110 0.011 0.109 -0.524 0.149 zAbsDDT 0.076 -0.065 0.125 -0.357 -0.186 0.146 convergence code: 0 Parameters or bounds appear to have different scalings. This can cause poor performance in optimization. It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.
%%R
main_CoM_model_exp2 = glmer(CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF +
zAbsDDT + (1 | Participant), data=CoM_data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
summary(main_CoM_model_exp2)
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod] Family: binomial ( logit ) Formula: CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT + (1 | Participant) Data: CoM_data_exp2 Control: glmerControl(optimizer = "optimx", optCtrl = list(method = "nlminb")) AIC BIC logLik deviance df.resid 1671.4 1717.3 -827.7 1655.4 2285 Scaled residuals: Min 1Q Median 3Q Max -2.0542 -0.4063 -0.2991 -0.2135 5.1792 Random effects: Groups Name Variance Std.Dev. Participant (Intercept) 0.1976 0.4445 Number of obs: 2293, groups: Participant, 24 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) -2.18699 0.11996 -18.231 < 2e-16 *** zAbsDV -0.08779 0.07188 -1.221 0.22191 zConf -0.44762 0.07073 -6.329 2.47e-10 *** zRT 0.31083 0.07611 4.084 4.43e-05 *** zSV 0.18307 0.06464 2.832 0.00463 ** zGSF 0.07960 0.07503 1.061 0.28876 zAbsDDT 0.04684 0.05343 0.877 0.38069 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) zAbsDV zConf zRT zSV zGSF zAbsDV 0.052 zConf 0.144 -0.130 zRT -0.155 0.010 0.228 zSV -0.051 0.215 -0.217 -0.104 zGSF -0.010 0.027 0.125 -0.584 0.108 zAbsDDT -0.011 -0.024 -0.058 -0.421 -0.030 0.235
%%R
fix_2b <- fixef(main_CoM_model_exp2)
fix_se_2b <- sqrt(diag(vcov(main_CoM_model_exp2)))
names_2b <- names(fix_2b)
correlation = np.round(stats.pearsonr(two_samples['zConf_Predicting_CoM'], two_samples['zMeta_Conf']), 3)
print "Pearson's r =", correlation[0], ' p=', correlation[1]
Pearson's r = -0.351 p= 0.011
%R -o fix_2a -o fix_se_2a -o names_2a
CoM_table_exp1 = regtable(fix_2a, fix_se_2a, names_2a)
CoM_table_exp1
cols = ['(Intercept)', 'zAbsDV', 'zConf', 'zRT', 'zSV', 'zGSF',
'zAbsDDT']
CoM_table_exp1 = CoM_table_exp1[cols]
CoM_table_exp1.columns = ['Intercept', '|DV|', 'Confidence',
'RT', 'SV', 'GSF', '|DDT|']
Coefpresplot(CoM_table_exp1, title='', ticklabsize=16, size='narrow',
ylimits=(-2, 1), ymultiple=1, n_ET_predictors=2)
[i.set_color('#03719c') for i in plt.gca().get_xticklabels()[4:]]
[None, None]
%R -o fix_2b -o fix_se_2b -o names_2b
CoM_table_exp2 = regtable(fix_2b, fix_se_2b, names_2b)
CoM_table_exp2
cols = ['(Intercept)', 'zAbsDV', 'zConf', 'zRT', 'zSV', 'zGSF',
'zAbsDDT']
CoM_table_exp2 = CoM_table_exp2[cols]
CoM_table_exp2.columns = ['Intercept', '|DV|', 'Confidence',
'RT', 'SV', 'GSF', '|DDT|']
Coefpresplot(CoM_table_exp2, title='', ticklabsize=16, size='narrow',
ylimits=(-1, 1), ymultiple=0.5, n_ET_predictors=2)
[i.set_color('#03719c') for i in plt.gca().get_xticklabels()[4:]]
[None, None]
f = plt.figure(figsize=(8, 8))
sns.set(style='white', font_scale=1.8)
ax = sns.regplot(data=two_samples[two_samples['Experiment']==1], x='zMeta_Conf', y='zConf_Predicting_CoM', fit_reg=False, ci=0, color='#000000', scatter_kws={'s':70})
sns.regplot(data=two_samples[two_samples['Experiment']==2], x='zMeta_Conf', y='zConf_Predicting_CoM', fit_reg=False, ci=0, color='#AAAAAA', marker='D', scatter_kws={'s':70})
ax.set(ylabel='Confidence Betas Predicting Changes of Mind', xlabel='Metacognitive Accuracy', xlim=(-3.5, 2.5))
exp1 = mpatches.Patch(color='#000000', label='Experiment 1')
exp2 = mpatches.Patch(color='#AAAAAA', label='Experiment 2')
plt.legend(handles=[exp1, exp2], loc=3)
x=two_samples['zMeta_Conf']
y=two_samples['zConf_Predicting_CoM']
fit = np.polyfit(x, y, deg=1)
future = np.arange(min(x)-0.2, max(x)+0.2, 0.01)
fit_fn = np.poly1d(fit)
future_fit = np.polyval(fit_fn, future)
ax.plot(future, future_fit, color='#555555', lw=3)
sns.despine()
%%R
proportions = prop.table(table(data_exp1$Transitivity_Violation, data_exp1$Conf_Dich), 1)
rownames(proportions) = c('Transitive Trials', 'Transitivity Violations')
colnames(proportions) = c('Low Confidence', 'High Confidence')
round(proportions*100, 2)
Low Confidence High Confidence Transitive Trials 48.66 51.34 Transitivity Violations 85.33 14.67
%%R
main_TV_model = glmer(Transitivity_Violation ~ zAbsDV + zConf + zRT + zSV +
zGSF + zAbsDDT + (zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT | Participant),
data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
summary(main_TV_model)
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod] Family: binomial ( logit ) Formula: Transitivity_Violation ~ zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT | Participant) Data: data_exp1 Control: glmerControl(optimizer = "optimx", optCtrl = list(method = "nlminb")) AIC BIC logLik deviance df.resid 2084.1 2322.5 -1007.0 2014.1 6685 Scaled residuals: Min 1Q Median 3Q Max -1.3278 -0.2126 -0.1187 -0.0648 14.5714 Random effects: Groups Name Variance Std.Dev. Corr Participant (Intercept) 0.37438 0.6119 zAbsDV 0.25727 0.5072 0.58 zConf 0.13933 0.3733 0.13 -0.49 zRT 0.09414 0.3068 -0.34 0.33 -0.68 zSV 0.08888 0.2981 -0.04 -0.13 0.16 -0.68 zGSF 0.04650 0.2156 0.77 0.70 0.23 -0.29 0.07 zAbsDDT 0.04848 0.2202 -0.20 -0.81 0.87 -0.64 0.28 -0.24 Number of obs: 6720, groups: Participant, 28 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) -4.19952 0.18141 -23.149 < 2e-16 *** zAbsDV -1.06462 0.16143 -6.595 4.26e-11 *** zConf -0.72159 0.10693 -6.748 1.50e-11 *** zRT 0.28094 0.11013 2.551 0.0107 * zSV 0.22153 0.08692 2.549 0.0108 * zGSF -0.17063 0.09790 -1.743 0.0814 . zAbsDDT -0.03763 0.08005 -0.470 0.6383 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) zAbsDV zConf zRT zSV zGSF zAbsDV 0.635 zConf 0.259 -0.258 zRT -0.162 0.114 -0.126 zSV -0.101 -0.092 -0.098 -0.268 zGSF 0.261 0.197 0.120 -0.596 -0.011 zAbsDDT -0.053 -0.260 0.313 -0.589 0.099 0.173 convergence code: 0 Parameters or bounds appear to have different scalings. This can cause poor performance in optimization. It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.
%%R
fix_3 <- fixef(main_TV_model)
fix_se_3 <- sqrt(diag(vcov(main_TV_model)))
names_3 <- names(fix_3)
results = pearsonr(par_data_exp1['Meta_Conf'], par_data_exp1['Trans_Viol_Change'])
print "Pearson's r = {0} ".format(np.round(results[0], 3)), "p = ", np.round(results[1], 3)
Pearson's r = 0.37 p = 0.053
%R -o fix_3 -o fix_se_3 -o names_3
TV_table = regtable(fix_3, fix_se_3, names_3)
TV_table.columns = ['Intercept', '|DV|', 'Confidence', 'RT', 'SV', 'GSF', '|DDT|']
Coefpresplot(TV_table, title='', ticklabsize=16, size='narrow', ylimits=(-1.5, 1), ymultiple=0.5, n_ET_predictors=2)
[i.set_color('#03719c') for i in plt.gca().get_xticklabels()[4:]]
#plt.savefig('figures/exp1_TV.png', bbox_inches='tight', dpi=600)
[None, None]
sns.set(style='white', font_scale=1, context='poster')
# building the graph
f = plt.figure(figsize=(14, 5)); gs = plt.GridSpec(7, 26); Tfull_ax = f.add_subplot(gs[0:6, 0:7])
Tlow_ax = f.add_subplot(gs[0:6, 7:14]); Thigh_ax = f.add_subplot(gs[0:6, 14:21]); Tbar_ax = f.add_subplot(gs[0:6, 21:23])
plt.tight_layout()
# assigning the heatmap
sns.heatmap(TransHeat_Norm, cmap="GnBu", vmin=-0.5, vmax=1, cbar=False, ax=Tfull_ax, linewidths=.5)
sns.heatmap(TransHeatHC_Norm, cmap="GnBu", vmin=-0.5, vmax=1, cbar=False, ax=Thigh_ax, linewidths=.5)
sns.heatmap(TransHeatLC_Norm, cmap="GnBu", vmin=-0.5, vmax=1, cbar=True, ax=Tlow_ax, cbar_ax=Tbar_ax, linewidths=.5)
# setting the
Tbar_ax.set_yticklabels([''])
Tfull_ax.set_xticklabels([]); Thigh_ax.set_xticklabels([]); Tlow_ax.set_xticklabels([])
Tfull_ax.set_yticklabels([]); Thigh_ax.set_yticklabels([]); Tlow_ax.set_yticklabels([])
Tbar_ax.set(ylabel="Transitivity Violations"); Tfull_ax.set(title='Full Dataset'); Thigh_ax.set(title='High Confidence Trials')
Tlow_ax.set(title='Low Confidence Trials');
#plt.savefig('figures/transitivity_heat2.png', dpi=600)
[<matplotlib.text.Text at 0x11f539bd0>]
f = plt.figure(figsize=(8, 8))
sns.set(style='white', font_scale=2.7)
gs = plt.GridSpec(1, 1)
l_ax = f.add_subplot(gs[0, 0])
sns.regplot("Meta_Conf", "Trans_Viol_Change", ci=0, color='#000000', fit_reg=False, scatter_kws={'s':70},
data=par_data_exp1, ax=l_ax)
l_ax.set(xlabel='Metacognitive Accuracy',)
plt.ylabel('Decrease in transitivity violations')
l_ax.xaxis.set_major_locator(MultipleLocator(2))
# Because seaborn doesn't let me draw a regression line that does not cut the axes I have to
# draw the regression line manually:
x=par_data_exp1['Meta_Conf']
y=par_data_exp1['Trans_Viol_Change']
fit = np.polyfit(x, y, deg=1)
future = np.arange(min(x)-1, max(x)+1, 0.01)
fit_fn = np.poly1d(fit)
future_fit = np.polyval(fit_fn, future)
l_ax.plot(future, future_fit, color='#000000', lw=3)
sns.despine()
log_data = data_exp2.copy()
log_data.columns
log_data = log_data[['Participant', 'Chosen_Position', 'zValue_Position_1', 'zValue_Position_2', 'zValue_Position_3',
'zDT_Position_1', 'zDT_Position_2', 'zDT_Position_3', 'zConf', 'zGSF', 'zSV']].copy()
log_data['Chosen_Position'] = log_data['Chosen_Position'].astype(object)
log_data.loc[log_data['Chosen_Position'] ==1, 'Chosen_Position'] = 'Position1'
log_data.loc[log_data['Chosen_Position'] ==2, 'Chosen_Position'] = 'Position2'
log_data.loc[log_data['Chosen_Position'] ==3, 'Chosen_Position'] = 'Position3'
log_data.columns = ['Participant', 'Choice', 'Value.Position1', 'Value.Position2', 'Value.Position3',
'DT.Position1', 'DT.Position2', 'DT.Position3', 'Confidence', 'GSF', 'Summed_Value']
log_data = log_data.dropna()
%R -i log_data
%%R
log_data <-mlogit.data(log_data, varying=3:8, choice="Choice", shape="wide") #Casting the data for
# the logit model
# Generating the interaction terms
log_data$Value_GSF = log_data$Value * log_data$GSF
log_data$Value_Conf = log_data$Value * log_data$Confidence
log_data$Value_Sum = log_data$Value * log_data$Summed_Value
log_data$Value_DT = log_data$Value * log_data$DT
%%R
logit_full <- mlogit(Choice ~ Value + DT + Value_Conf + Value_Sum + Value_GSF
| Confidence + Summed_Value + GSF, data=log_data, reflevel="Position1")
summary(logit_full)
Call: mlogit(formula = Choice ~ Value + DT + Value_Conf + Value_Sum + Value_GSF | Confidence + Summed_Value + GSF, data = log_data, reflevel = "Position1", method = "nr", print.level = 0) Frequencies of alternatives: Position1 Position2 Position3 0.34069 0.32617 0.33314 nr method 6 iterations, 0h:0m:0s g'(-H)^-1g = 1.98E-05 successive function values within tolerance limits Coefficients : Estimate Std. Error t-value Pr(>|t|) Position2:(intercept) 0.110877 0.052073 2.1292 0.0332340 * Position3:(intercept) 0.260732 0.052427 4.9733 6.583e-07 *** Value 0.626779 0.040068 15.6429 < 2.2e-16 *** DT 1.608205 0.052085 30.8765 < 2.2e-16 *** Value_Conf 0.158009 0.042647 3.7051 0.0002113 *** Value_Sum -0.143190 0.038454 -3.7237 0.0001963 *** Value_GSF 0.052417 0.044628 1.1745 0.2401767 Position2:Confidence 0.021252 0.059820 0.3553 0.7223900 Position3:Confidence -0.016987 0.059871 -0.2837 0.7766151 Position2:Summed_Value -0.035676 0.052759 -0.6762 0.4989128 Position3:Summed_Value -0.037643 0.052429 -0.7180 0.4727713 Position2:GSF -0.048008 0.060952 -0.7876 0.4309142 Position3:GSF 0.125699 0.060280 2.0852 0.0370477 * --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Log-Likelihood: -2586.8 McFadden R^2: 0.31602 Likelihood ratio test : chisq = 2390.3 (p.value = < 2.22e-16)
Note that gaze shift frequency did predict choosing the third option, meaning that participants were more likely to choose the third option when they shifted their gaze more. This might be because people tend to look more at the first option and tend to choose the option they look at more. Trials with more gaze shifting mitigates this bias. The analyses below show that dwell time is less strongly predicted by position in trials when GSF is high, and that the influence of GSF in predicting choosing the third option disappears when dwell time is excluded from the model.
%%R
log_data2 = log_data
test = as.character(rownames(log_data2))
test2 = strsplit(test, "P")
test3 = sapply(test2, "[[", 2)
log_data2['Position'] = paste("P", sep='', test3)
%%R
multi_eye = lm(DT ~ Position + Value + Position*GSF, data=log_data2)
summary(multi_eye)
Call: lm(formula = DT ~ Position + Value + Position * GSF, data = log_data2) Residuals: Min 1Q Median 3Q Max -3.0547 -0.5134 -0.1735 0.2832 16.3612 Coefficients: Estimate Std. Error t value Pr(>|t|) (Intercept) 0.081412 0.014917 5.458 4.93e-08 *** PositionPosition2 -0.065540 0.021095 -3.107 0.0019 ** PositionPosition3 -0.184370 0.021095 -8.740 < 2e-16 *** Value 0.121499 0.008667 14.019 < 2e-16 *** GSF 0.492450 0.014997 32.836 < 2e-16 *** PositionPosition2:GSF 0.021084 0.021199 0.995 0.3200 PositionPosition3:GSF -0.096068 0.021205 -4.531 5.95e-06 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Residual standard error: 0.8753 on 10322 degrees of freedom Multiple R-squared: 0.2327, Adjusted R-squared: 0.2322 F-statistic: 521.6 on 6 and 10322 DF, p-value: < 2.2e-16
%%R
logit_full2 <- mlogit(Choice ~ Value + Value_Conf + Value_Sum + Value_GSF
| Confidence + Summed_Value + GSF, data=log_data, reflevel="Position1")
summary(logit_full2)
Call: mlogit(formula = Choice ~ Value + Value_Conf + Value_Sum + Value_GSF | Confidence + Summed_Value + GSF, data = log_data, reflevel = "Position1", method = "nr", print.level = 0) Frequencies of alternatives: Position1 Position2 Position3 0.34069 0.32617 0.33314 nr method 4 iterations, 0h:0m:0s g'(-H)^-1g = 9.96E-07 gradient close to zero Coefficients : Estimate Std. Error t-value Pr(>|t|) Position2:(intercept) -0.0188557 0.0437878 -0.4306 0.6667 Position3:(intercept) -0.0322517 0.0442972 -0.7281 0.4666 Value 0.7514381 0.0345936 21.7219 < 2.2e-16 *** Value_Conf 0.1478785 0.0352577 4.1942 2.738e-05 *** Value_Sum -0.1824297 0.0330040 -5.5275 3.248e-08 *** Value_GSF 0.0242301 0.0367215 0.6598 0.5094 Position2:Confidence 0.0456081 0.0491812 0.9273 0.3537 Position3:Confidence -0.0270125 0.0500745 -0.5394 0.5896 Position2:Summed_Value -0.0043713 0.0441673 -0.0990 0.9212 Position3:Summed_Value -0.0134636 0.0445068 -0.3025 0.7623 Position2:GSF 0.0092963 0.0487063 0.1909 0.8486 Position3:GSF -0.0092383 0.0486768 -0.1898 0.8495 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Log-Likelihood: -3443.9 McFadden R^2: 0.089388 Likelihood ratio test : chisq = 676.12 (p.value = < 2.22e-16)
%%R
eye_model_1 = glmer(Chose_right ~ zDV + zDDT + zGSF + zDV:zDDT + zDV:zGSF +
(zDV + zDDT + zGSF + zDV:zDDT + zDV:zGSF | Participant),
data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
summary(eye_model_1)
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod] Family: binomial ( logit ) Formula: Chose_right ~ zDV + zDDT + zGSF + zDV:zDDT + zDV:zGSF + (zDV + zDDT + zGSF + zDV:zDDT + zDV:zGSF | Participant) Data: data_exp1 Control: glmerControl(optimizer = "optimx", optCtrl = list(method = "nlminb")) AIC BIC logLik deviance df.resid 4074.0 4257.9 -2010.0 4020.0 6693 Scaled residuals: Min 1Q Median 3Q Max -13.0885 -0.2656 -0.0026 0.2649 10.2768 Random effects: Groups Name Variance Std.Dev. Corr Participant (Intercept) 0.01010 0.1005 zDV 2.15205 1.4670 -0.43 zDDT 0.82069 0.9059 0.15 -0.31 zGSF 0.01920 0.1385 -0.98 0.38 0.02 zDV:zDDT 0.02352 0.1534 0.95 -0.69 0.20 -0.93 zDV:zGSF 0.04029 0.2007 0.84 -0.51 -0.32 -0.91 0.86 Number of obs: 6720, groups: Participant, 28 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) -0.07556 0.04837 -1.562 0.118 zDV 3.61482 0.30129 11.998 < 2e-16 *** zDDT 0.91813 0.17946 5.116 3.12e-07 *** zGSF 0.06017 0.04849 1.241 0.215 zDV:zDDT -0.12663 0.10969 -1.154 0.248 zDV:zGSF -0.39969 0.10117 -3.951 7.80e-05 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) zDV zDDT zGSF zDV:DD zDV -0.181 zDDT 0.052 -0.259 zGSF -0.407 0.203 0.022 zDV:zDDT 0.185 -0.190 0.038 -0.118 zDV:zGSF 0.143 -0.270 -0.104 -0.217 0.035 convergence code: 0 Parameters or bounds appear to have different scalings. This can cause poor performance in optimization. It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.
%%R
eye_model_2 = glmer(Chose_Item_1 ~ zItem1_DV + zItem1_DDT + zGSF + zItem1_DV:zItem1_DDT +
zItem1_DV:zGSF + (zItem1_DV + zItem1_DDT + zGSF + zItem1_DV:zItem1_DDT +
zItem1_DV:zGSF | Participant), data=data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
summary(eye_model_2)
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod] Family: binomial ( logit ) Formula: Chose_Item_1 ~ zItem1_DV + zItem1_DDT + zGSF + zItem1_DV:zItem1_DDT + zItem1_DV:zGSF + (zItem1_DV + zItem1_DDT + zGSF + zItem1_DV:zItem1_DDT + zItem1_DV:zGSF | Participant) Data: data_exp2 Control: glmerControl(optimizer = "optimx", optCtrl = list(method = "nlminb")) AIC BIC logLik deviance df.resid 2745.9 2911.8 -1345.9 2691.9 3416 Scaled residuals: Min 1Q Median 3Q Max -25.083 -0.441 -0.167 0.364 89.084 Random effects: Groups Name Variance Std.Dev. Corr Participant (Intercept) 0.06718 0.2592 zItem1_DV 0.59161 0.7692 -0.71 zItem1_DDT 0.74342 0.8622 -0.47 -0.28 zGSF 0.02511 0.1585 0.21 0.17 -0.51 zItem1_DV:zItem1_DDT 0.17736 0.4211 0.44 0.14 -0.77 -0.15 zItem1_DV:zGSF 0.02646 0.1627 0.46 -0.25 -0.31 -0.62 0.82 Number of obs: 3443, groups: Participant, 24 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) -1.18852 0.07935 -14.978 < 2e-16 *** zItem1_DV 1.30821 0.17622 7.424 1.14e-13 *** zItem1_DDT 1.84580 0.19890 9.280 < 2e-16 *** zGSF -0.12089 0.06480 -1.865 0.06211 . zItem1_DV:zItem1_DDT -0.30662 0.14118 -2.172 0.02987 * zItem1_DV:zGSF -0.25590 0.08507 -3.008 0.00263 ** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) zIt1_DV zI1_DD zGSF zI1_DV:I zItem1_DV -0.551 zItem1_DDT -0.406 -0.193 zGSF 0.075 0.089 -0.299 zI1_DV:I1_D 0.252 -0.039 -0.551 -0.011 zIt1_DV:GSF 0.129 -0.060 -0.069 -0.372 0.080 convergence code: 0 unable to evaluate scaled gradient Model failed to converge: degenerate Hessian with 1 negative eigenvalues Parameters or bounds appear to have different scalings. This can cause poor performance in optimization. It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.
logisticplot_all(moderator='DDT_Dich', modhigh=' ', modlow=' ',
data=data_exp1, xaxis='zDV', yaxis='Chose_right', xlab='DV (Z-score)',
modhighcol=ten_aqua[3], modlowcol=ten_aqua[9], title='empty',
parvar='Participant')
plt.tight_layout()
#plt.savefig('../figures/Logistic_DDT_3_Opts.png', dpi=600)
logisticplot_all(moderator='DDT_Dich', modhigh=' ', modlow=' ',
data=data_exp2, xaxis='zItem1_DV', yaxis='Chose_Item_1', xlab='DV (Z-score)',
modhighcol=ten_aqua[3], modlowcol=ten_aqua[9], title='empty',
parvar='Participant')
plt.tight_layout()
#plt.savefig('../../figures/Logistic_DDT_3_Opts.png', dpi=600)
logisticplot_all(moderator='GSF_Dich', modhigh=' ', modlow=' ',
data=data_exp1, xaxis='zDV', yaxis='Chose_right', xlab='DV (Z-score)',
modhighcol=ten_aqua[3], modlowcol=ten_aqua[9], title='empty',
parvar='Participant')
plt.tight_layout()
logisticplot_all(moderator='GSF_Dich', modhigh=' ', modlow=' ',
data=data_exp2, xaxis='zItem1_DV', yaxis='Chose_Item_1', xlab='DV (Z-score)',
modhighcol=ten_aqua[3], modlowcol=ten_aqua[9], title='empty',
parvar='Participant')
plt.tight_layout()
#plt.savefig('../figures/Logistic_DDT_3_Opts.png', dpi=600)
choice_models = ['Empty', 'Model 1', 'Model 2', 'Model 3', 'Model 4', 'Model 5',
'Model 6', 'Model 7']
choice_formulas = ['Choice ~ 1', 'Choice ~ Difference in Value', 'Choice ~ Difference in Value + Confidence',
'Choice ~ Difference in Value + Confidence + Summed Value',
'Choice ~ Difference in Value + Confidence + Summed Value + Difference in Dwell Time',
'Choice ~ Difference in Value + Confidence + Summed Value + Difference in Dwell Time + Difference in Value * Confidence',
'Choice ~ Difference in Value + Confidence + Summed Value + Difference in Dwell Time + Difference in Value * Confidence + Difference in Value * Summed Value',
'Choice ~ Difference in Value + Confidence + Summed Value + Difference in Dwell Time + Gaze Shift Frequency + Difference in Value * Confidence + Difference in Value * Summed Value + Difference in Value * Gaze Shift Frequency']
Choice_Table = pd.DataFrame([choice_models, choice_formulas])
Choice_Table = Choice_Table.transpose(); Choice_Table.columns = ['Models', 'Formulas']
pd.set_option('max_colwidth', 300)
Choice_Table
Models | Formulas | |
---|---|---|
0 | Empty | Choice ~ 1 |
1 | Model 1 | Choice ~ Difference in Value |
2 | Model 2 | Choice ~ Difference in Value + Confidence |
3 | Model 3 | Choice ~ Difference in Value + Confidence + Summed Value |
4 | Model 4 | Choice ~ Difference in Value + Confidence + Summed Value + Difference in Dwell Time |
5 | Model 5 | Choice ~ Difference in Value + Confidence + Summed Value + Difference in Dwell Time + Difference in Value * Confidence |
6 | Model 6 | Choice ~ Difference in Value + Confidence + Summed Value + Difference in Dwell Time + Difference in Value * Confidence + Difference in Value * Summed Value |
7 | Model 7 | Choice ~ Difference in Value + Confidence + Summed Value + Difference in Dwell Time + Gaze Shift Frequency + Difference in Value * Confidence + Difference in Value * Summed Value + Difference in Value * Gaze Shift Frequency |
%%R
choice_emptya = glmer(Chose_right ~ 1 + (1 | Participant), data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
choice_model_1a = glmer(Chose_right ~ zDV + (zDV | Participant), data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
choice_model_2a = glmer(Chose_right ~ zDV + zConf + (zDV + zConf | Participant), data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
choice_model_3a = glmer(Chose_right ~ zDV + zConf + zSV + (zDV + zConf + zSV | Participant),
data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
choice_model_4a = glmer(Chose_right ~ zDV + zConf + zSV + zDDT + (zDV + zConf
+ zSV + zDDT | Participant),
data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
choice_model_5a = glmer(Chose_right ~ zDV + zConf + zSV + zDDT + zConf:zDV +
(zDV + zConf + zSV + zDDT + zConf:zDV | Participant),
data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
choice_model_6a = glmer(Chose_right ~ zDV + zConf + zSV + zDDT + zConf:zDV + zSV:zDV +
(zDV + zConf + zSV + zDDT + zConf:zDV + zSV:zDV | Participant),
data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
choice_model_7a = glmer(Chose_right ~ zDV + zConf + zSV + zDDT + zConf:zDV + zSV:zDV +
zGSF + zGSF:zDV + (zDV + zConf + zSV + zDDT + zConf:zDV + zSV:zDV +
zGSF + zGSF:zDV | Participant),
data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
%%R
comparison1a =anova(choice_emptya, choice_model_1a, choice_model_2a,
choice_model_3a, choice_model_4a, choice_model_5a,
choice_model_6a, choice_model_7a)
BIC1a = list(comparison1a$BIC)
%%R
comparison1a
Data: data_exp1 Models: choice_emptya: Chose_right ~ 1 + (1 | Participant) choice_model_1a: Chose_right ~ zDV + (zDV | Participant) choice_model_2a: Chose_right ~ zDV + zConf + (zDV + zConf | Participant) choice_model_3a: Chose_right ~ zDV + zConf + zSV + (zDV + zConf + zSV | Participant) choice_model_4a: Chose_right ~ zDV + zConf + zSV + zDDT + (zDV + zConf + zSV + choice_model_4a: zDDT | Participant) choice_model_5a: Chose_right ~ zDV + zConf + zSV + zDDT + zConf:zDV + (zDV + zConf + choice_model_5a: zSV + zDDT + zConf:zDV | Participant) choice_model_6a: Chose_right ~ zDV + zConf + zSV + zDDT + zConf:zDV + zSV:zDV + choice_model_6a: (zDV + zConf + zSV + zDDT + zConf:zDV + zSV:zDV | Participant) choice_model_7a: Chose_right ~ zDV + zConf + zSV + zDDT + zConf:zDV + zSV:zDV + choice_model_7a: zGSF + zGSF:zDV + (zDV + zConf + zSV + zDDT + zConf:zDV + choice_model_7a: zSV:zDV + zGSF + zGSF:zDV | Participant) Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq) choice_emptya 2 9319.0 9332.6 -4657.5 9315.0 choice_model_1a 5 4631.7 4665.7 -2310.8 4621.7 4693.3309 3 < 2e-16 choice_model_2a 9 4636.7 4698.0 -2309.3 4618.7 2.9861 4 0.5602 choice_model_3a 14 4645.5 4740.9 -2308.7 4617.5 1.1804 5 0.9467 choice_model_4a 20 4083.8 4220.0 -2021.9 4043.8 573.7305 6 < 2e-16 choice_model_5a 27 3956.5 4140.4 -1951.2 3902.5 141.2879 7 < 2e-16 choice_model_6a 35 3903.7 4142.1 -1916.8 3833.7 68.8039 8 8.5e-12 choice_model_7a 54 3929.6 4297.5 -1910.8 3821.6 12.1078 19 0.8810 choice_emptya choice_model_1a *** choice_model_2a choice_model_3a choice_model_4a *** choice_model_5a *** choice_model_6a *** choice_model_7a --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
%R -o BIC1a
BIC1a = np.array(BIC1a); BIC1a = BIC1a[0]
Choice_Table['BIC'] = BIC1a
BIC_bar(Choice_Table.loc[1:, :].copy().reset_index(drop=True), title='')
plt.tight_layout()
#plt.savefig('../../figures/exp1_choice_models.png', dpi=600)
%%R
choice_emptyb = glmer(Chose_Item_1 ~ 1 + (1 | Participant), data=data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
choice_model_1b = glmer(Chose_Item_1 ~ zItem1_DV + (zItem1_DV | Participant), data=data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
choice_model_2b = glmer(Chose_Item_1 ~ zItem1_DV + zConf + (zItem1_DV + zConf | Participant), data=data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
choice_model_3b = glmer(Chose_Item_1 ~ zItem1_DV + zConf + zSV + (zItem1_DV + zConf + zSV | Participant),
data=data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
choice_model_4b = glmer(Chose_Item_1 ~ zItem1_DV + zConf + zSV + zItem1_DDT + (zItem1_DV + zConf
+ zSV + zItem1_DDT | Participant),
data=data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
choice_model_5b = glmer(Chose_Item_1 ~ zItem1_DV + zConf + zSV + zItem1_DDT + zConf:zItem1_DV +
(zItem1_DV + zConf + zSV + zItem1_DDT + zConf:zItem1_DV | Participant),
data=data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
choice_model_6b = glmer(Chose_Item_1 ~ zItem1_DV + zConf + zSV + zItem1_DDT + zConf:zItem1_DV +
zSV:zItem1_DV + (zItem1_DV + zConf + zSV + zItem1_DDT + zConf:zItem1_DV +
zSV:zItem1_DV | Participant),
data=data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
choice_model_7b = glmer(Chose_Item_1 ~ zItem1_DV + zConf + zSV + zItem1_DDT + zConf:zItem1_DV
+ zSV:zItem1_DV + zGSF + zGSF:zItem1_DV + (zItem1_DV + zConf + zSV
+ zItem1_DDT + zConf:zItem1_DV + zSV:zItem1_DV + zGSF + zGSF:zItem1_DV | Participant),
data=data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
%%R
comparison1b =anova(choice_emptyb, choice_model_1b, choice_model_2b,
choice_model_3b, choice_model_4b, choice_model_5b,
choice_model_6b, choice_model_7b)
BIC1b = list(comparison1b$BIC)
%%R
comparison1b
Data: data_exp2 Models: choice_emptyb: Chose_Item_1 ~ 1 + (1 | Participant) choice_model_1b: Chose_Item_1 ~ zItem1_DV + (zItem1_DV | Participant) choice_model_2b: Chose_Item_1 ~ zItem1_DV + zConf + (zItem1_DV + zConf | Participant) choice_model_3b: Chose_Item_1 ~ zItem1_DV + zConf + zSV + (zItem1_DV + zConf + choice_model_3b: zSV | Participant) choice_model_4b: Chose_Item_1 ~ zItem1_DV + zConf + zSV + zItem1_DDT + (zItem1_DV + choice_model_4b: zConf + zSV + zItem1_DDT | Participant) choice_model_5b: Chose_Item_1 ~ zItem1_DV + zConf + zSV + zItem1_DDT + zConf:zItem1_DV + choice_model_5b: (zItem1_DV + zConf + zSV + zItem1_DDT + zConf:zItem1_DV | choice_model_5b: Participant) choice_model_6b: Chose_Item_1 ~ zItem1_DV + zConf + zSV + zItem1_DDT + zConf:zItem1_DV + choice_model_6b: zSV:zItem1_DV + (zItem1_DV + zConf + zSV + zItem1_DDT + zConf:zItem1_DV + choice_model_6b: zSV:zItem1_DV | Participant) choice_model_7b: Chose_Item_1 ~ zItem1_DV + zConf + zSV + zItem1_DDT + zConf:zItem1_DV + choice_model_7b: zSV:zItem1_DV + zGSF + zGSF:zItem1_DV + (zItem1_DV + zConf + choice_model_7b: zSV + zItem1_DDT + zConf:zItem1_DV + zSV:zItem1_DV + zGSF + choice_model_7b: zGSF:zItem1_DV | Participant) Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq) choice_emptyb 2 4421.3 4433.6 -2208.7 4417.3 choice_model_1b 5 3536.8 3567.5 -1763.4 3526.8 890.4931 3 < 2.2e-16 choice_model_2b 9 3543.4 3598.7 -1762.7 3525.4 1.4411 4 0.83703 choice_model_3b 14 3545.6 3631.6 -1758.8 3517.6 7.7821 5 0.16866 choice_model_4b 20 2774.0 2896.9 -1367.0 2734.0 783.6182 6 < 2.2e-16 choice_model_5b 27 2739.2 2905.1 -1342.6 2685.2 48.7539 7 2.535e-08 choice_model_6b 35 2741.9 2956.9 -1335.9 2671.9 13.3779 8 0.09949 choice_model_7b 54 2765.2 3097.0 -1328.6 2657.2 14.6395 19 0.74522 choice_emptyb choice_model_1b *** choice_model_2b choice_model_3b choice_model_4b *** choice_model_5b *** choice_model_6b . choice_model_7b --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
%R -o BIC1b
BIC1b = np.array(BIC1b); BIC1b = BIC1b[0]
BIC1b
array([ 4433.60844898, 3567.54764027, 3598.68297347, 3631.62133092, 2896.86770687, 2905.12248318, 2956.89735993, 3096.99569625])
Choice_Table['BIC'] = BIC1b
BIC_bar(Choice_Table.loc[1:, :].copy().reset_index(drop=True), title='')
plt.tight_layout()
#plt.savefig('../../figures/exp2_choice_models.png', dpi=600)
confidence_models = ['Model 1', 'Model 2', 'Model 3', 'Model 4', 'Model 5']
confidence_formulas = ['Confidence ~ |Difference in Value|', 'Confidence ~ |Difference in Value| + Response Time',
'Confidence ~ |Difference in Value| + Response Time + Gaze Shift Frequency',
'Confidence ~ |Difference in Value| + Response Time + Gaze Shift Frequency + Summed Value',
'Confidence ~ |Difference in Value| + Response Time + Gaze Shift Frequency + Summed Value + Difference in Dwell Time']
Confidence_1_Table = pd.DataFrame([confidence_models, confidence_formulas])
Confidence_1_Table = Confidence_1_Table.transpose(); Confidence_1_Table.columns = ['Models', 'Formulas']
Confidence_1_Table
Models | Formulas | |
---|---|---|
0 | Model 1 | Confidence ~ |Difference in Value| |
1 | Model 2 | Confidence ~ |Difference in Value| + Response Time |
2 | Model 3 | Confidence ~ |Difference in Value| + Response Time + Gaze Shift Frequency |
3 | Model 4 | Confidence ~ |Difference in Value| + Response Time + Gaze Shift Frequency + Summed Value |
4 | Model 5 | Confidence ~ |Difference in Value| + Response Time + Gaze Shift Frequency + Summed Value + Difference in Dwell Time |
%%R
confidence_model_1a = lmer(zConf ~ 0 + zAbsDV + (0 + zAbsDV | Participant), data=data_exp1,
control=lmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
confidence_model_2a = lmer(zConf ~ 0 + zAbsDV + zRT + (0 + zAbsDV + zRT | Participant), data=data_exp1,
control=lmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
confidence_model_3a = lmer(zConf ~ 0 + zAbsDV + zRT + zGSF + (0 + zAbsDV
+ zGSF + zRT | Participant), data=data_exp1,
control=lmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
confidence_model_4a = lmer(zConf ~ 0 + zAbsDV + zRT + zGSF + zSV + (0 + zAbsDV
+ zGSF + zRT + zSV | Participant), data=data_exp1,
control=lmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
confidence_model_5a = lmer(zConf ~ 0 + zAbsDV + zRT + zGSF + zSV + zAbsDDT + (0 + zAbsDV
+ zGSF + zRT + zSV + zAbsDDT| Participant), data=data_exp1,
control=lmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
/Users/Tomas/anaconda/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: Model failed to converge with max|grad| = 0.041077 (tol = 0.002, component 1) res = super(Function, self).__call__(*new_args, **new_kwargs)
%%R
comparison2a =anova(confidence_model_1a, confidence_model_2a,
confidence_model_3a, confidence_model_4a, confidence_model_5a)
BIC2a = list(comparison2a$BIC)
%%R
comparison2a
Data: data_exp1 Models: confidence_model_1a: zConf ~ 0 + zAbsDV + (0 + zAbsDV | Participant) confidence_model_2a: zConf ~ 0 + zAbsDV + zRT + (0 + zAbsDV + zRT | Participant) confidence_model_3a: zConf ~ 0 + zAbsDV + zRT + zGSF + (0 + zAbsDV + zGSF + zRT | confidence_model_3a: Participant) confidence_model_4a: zConf ~ 0 + zAbsDV + zRT + zGSF + zSV + (0 + zAbsDV + zGSF + confidence_model_4a: zRT + zSV | Participant) confidence_model_5a: zConf ~ 0 + zAbsDV + zRT + zGSF + zSV + zAbsDDT + (0 + zAbsDV + confidence_model_5a: zGSF + zRT + zSV + zAbsDDT | Participant) Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq) confidence_model_1a 3 17494 17514 -8743.9 17488 confidence_model_2a 6 16304 16344 -8145.7 16292 1196.409 3 < 2.2e-16 confidence_model_3a 10 16272 16340 -8125.9 16252 39.696 4 5.002e-08 confidence_model_4a 15 15427 15530 -7698.6 15397 854.499 5 < 2.2e-16 confidence_model_5a 21 15426 15569 -7692.1 15384 13.057 6 0.04214 confidence_model_1a confidence_model_2a *** confidence_model_3a *** confidence_model_4a *** confidence_model_5a * --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
Confidence_1_Table['BIC']
0 17514.320404 1 16344.349831 2 16339.904965 3 15529.469891 4 15569.290092 Name: BIC, dtype: float64
%R -o BIC2a
BIC2a = np.array(BIC2a); Confidence_1_Table['BIC'] = BIC2a[0]
BIC_bar(Confidence_1_Table.loc[0:, :].copy().reset_index(drop=True), title='')
plt.tight_layout()
#plt.savefig('../../figures/exp1_confidence_models.png', dpi=600)
%%R
confidence_model_1b = lmer(zConf ~ 0 + zAbsDV + (0 + zAbsDV | Participant), data=data_exp2,
control=lmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
confidence_model_2b = lmer(zConf ~ 0 + zAbsDV + zRT + (0 + zAbsDV + zRT | Participant), data=data_exp2,
control=lmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
confidence_model_3b = lmer(zConf ~ 0 + zAbsDV + zRT + zGSF + (0 + zAbsDV
+ zGSF + zRT | Participant), data=data_exp2,
control=lmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
confidence_model_4b = lmer(zConf ~ 0 + zAbsDV + zRT + zGSF + zSV + (0 + zAbsDV
+ zGSF + zRT + zSV | Participant), data=data_exp2,
control=lmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
confidence_model_5b = lmer(zConf ~ 0 + zAbsDV + zRT + zGSF + zSV + zAbsDDT + (0 + zAbsDV
+ zGSF + zRT + zSV + zAbsDDT | Participant), data=data_exp2,
control=lmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
%%R
comparison2b =anova(confidence_model_1b, confidence_model_2b,
confidence_model_3b, confidence_model_4b, confidence_model_5b)
BIC2b = list(comparison2b$BIC)
%%R
comparison2b
Data: data_exp2 Models: confidence_model_1b: zConf ~ 0 + zAbsDV + (0 + zAbsDV | Participant) confidence_model_2b: zConf ~ 0 + zAbsDV + zRT + (0 + zAbsDV + zRT | Participant) confidence_model_3b: zConf ~ 0 + zAbsDV + zRT + zGSF + (0 + zAbsDV + zGSF + zRT | confidence_model_3b: Participant) confidence_model_4b: zConf ~ 0 + zAbsDV + zRT + zGSF + zSV + (0 + zAbsDV + zGSF + confidence_model_4b: zRT + zSV | Participant) confidence_model_5b: zConf ~ 0 + zAbsDV + zRT + zGSF + zSV + zAbsDDT + (0 + zAbsDV + confidence_model_5b: zGSF + zRT + zSV + zAbsDDT | Participant) Df AIC BIC logLik deviance Chisq Chi Df confidence_model_1b 3 9550.3 9568.8 -4772.2 9544.3 confidence_model_2b 6 8763.6 8800.5 -4375.8 8751.6 792.6921 3 confidence_model_3b 10 8636.6 8698.0 -4308.3 8616.6 135.0871 4 confidence_model_4b 15 8344.7 8436.9 -4157.4 8314.7 301.8272 5 confidence_model_5b 21 8351.9 8480.9 -4154.9 8309.9 4.8457 6 Pr(>Chisq) confidence_model_1b confidence_model_2b <2e-16 *** confidence_model_3b <2e-16 *** confidence_model_4b <2e-16 *** confidence_model_5b 0.5637 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
%R -o BIC2b
BIC2b = np.array(BIC2b); Confidence_1_Table['BIC'] = BIC2b[0]
BIC_bar(Confidence_1_Table.loc[1:, :].copy().reset_index(drop=True), title='')
plt.tight_layout()
#plt.savefig('../../figures/exp2_confidence_models.png', dpi=600)
CoM_models = ['Empty', 'Model 1', 'Model 2', 'Model 3', 'Model 4', 'Model 5', 'Model 6', 'Model 7']
CoM_formulas = ['Change of Mind ~ 1', 'Change of Mind ~ |Difference in Value|', 'Change of Mind ~ |Difference in Value| + Confidence',
'Change of Mind ~ |Difference in Value| + Confidence + Response Time',
'Change of Mind ~ |Difference in Value| + Confidence + Response Time + Summed Value',
'Change of Mind ~ |Difference in Value| + Confidence + Response Time + Summed Value + Gaze Shift Frequency',
'Change of Mind ~ |Difference in Value| + Confidence + Response Time + Summed Value + Gaze Shift Frequency + |Difference in Dwell Time|',
'Change of Mind ~ |Difference in Value| + Response Time + Summed Value + Gaze Shift Frequency + |Difference in Dwell Time|']
CoM_Table = pd.DataFrame([CoM_models, CoM_formulas])
CoM_Table = CoM_Table.transpose(); CoM_Table.columns = ['Models', 'Formulas']
pd.set_option('max_colwidth', 200)
CoM_Table
Models | Formulas | |
---|---|---|
0 | Empty | Change of Mind ~ 1 |
1 | Model 1 | Change of Mind ~ |Difference in Value| |
2 | Model 2 | Change of Mind ~ |Difference in Value| + Confidence |
3 | Model 3 | Change of Mind ~ |Difference in Value| + Confidence + Response Time |
4 | Model 4 | Change of Mind ~ |Difference in Value| + Confidence + Response Time + Summed Value |
5 | Model 5 | Change of Mind ~ |Difference in Value| + Confidence + Response Time + Summed Value + Gaze Shift Frequency |
6 | Model 6 | Change of Mind ~ |Difference in Value| + Confidence + Response Time + Summed Value + Gaze Shift Frequency + |Difference in Dwell Time| |
7 | Model 7 | Change of Mind ~ |Difference in Value| + Response Time + Summed Value + Gaze Shift Frequency + |Difference in Dwell Time| |
%%R
CoM_emptya = glmer(CoM_Next ~ 1 + (1 | Participant), data=CoM_data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
CoM_model_1a = glmer(CoM_Next ~ zAbsDV + (zAbsDV | Participant), data=CoM_data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
CoM_model_2a = glmer(CoM_Next ~ zAbsDV + zConf + (zAbsDV + zConf | Participant), data=CoM_data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
CoM_model_3a = glmer(CoM_Next ~ zAbsDV + zConf + zRT + (zAbsDV + zConf + zRT | Participant),
data=CoM_data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
CoM_model_4a = glmer(CoM_Next ~ zAbsDV + zConf + zRT + zSV + (zAbsDV + zConf + zRT +
zSV | Participant), data=CoM_data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
CoM_model_5a = glmer(CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF + (zAbsDV + zConf + zRT +
zSV + zGSF | Participant), data=CoM_data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
CoM_model_6a = glmer(CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zConf + zRT +
zSV + zGSF + zAbsDDT | Participant), data=CoM_data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
CoM_model_7a = glmer(CoM_Next ~ zAbsDV + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zRT +
zSV + zGSF + zAbsDDT | Participant), data=CoM_data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
%%R
comparison3a =anova(CoM_emptya, CoM_model_1a, CoM_model_2a,
CoM_model_3a, CoM_model_4a, CoM_model_5a,
CoM_model_6a, CoM_model_7a)
BIC3a = list(comparison3a$BIC)
%%R
comparison3a
Data: CoM_data_exp1 Models: CoM_emptya: CoM_Next ~ 1 + (1 | Participant) CoM_model_1a: CoM_Next ~ zAbsDV + (zAbsDV | Participant) CoM_model_2a: CoM_Next ~ zAbsDV + zConf + (zAbsDV + zConf | Participant) CoM_model_3a: CoM_Next ~ zAbsDV + zConf + zRT + (zAbsDV + zConf + zRT | Participant) CoM_model_4a: CoM_Next ~ zAbsDV + zConf + zRT + zSV + (zAbsDV + zConf + zRT + CoM_model_4a: zSV | Participant) CoM_model_5a: CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF + (zAbsDV + zConf + CoM_model_5a: zRT + zSV + zGSF | Participant) CoM_model_7a: CoM_Next ~ zAbsDV + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zRT + CoM_model_7a: zSV + zGSF + zAbsDDT | Participant) CoM_model_6a: CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + CoM_model_6a: zConf + zRT + zSV + zGSF + zAbsDDT | Participant) Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq) CoM_emptya 2 1911.0 1923.2 -953.49 1907.0 CoM_model_1a 5 1689.0 1719.6 -839.51 1679.0 227.960 3 < 2.2e-16 *** CoM_model_2a 9 1614.5 1669.6 -798.25 1596.5 82.525 4 < 2.2e-16 *** CoM_model_3a 14 1592.0 1677.6 -781.98 1564.0 32.545 5 4.633e-06 *** CoM_model_4a 20 1580.4 1702.8 -770.19 1540.4 23.577 6 0.0006246 *** CoM_model_5a 27 1584.2 1749.5 -765.12 1530.2 10.142 7 0.1806543 CoM_model_7a 27 1643.7 1808.9 -794.85 1589.7 0.000 0 1.0000000 CoM_model_6a 35 1599.5 1813.7 -764.77 1529.5 60.166 8 4.324e-10 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
%R -o BIC3a
BIC3a = np.array(BIC3a); CoM_Table['BIC'] = np.append(BIC3a[0][:6], (BIC3a[0][7], BIC3a[0][6]))
BIC_bar(CoM_Table.loc[1:, :].copy().reset_index(drop=True), title='')
plt.tight_layout()
#plt.savefig('../../figures/exp1_CoM_models.png', dpi=600)
%%R
CoM_emptyb = glmer(CoM_Next ~ 1 + (1 | Participant), data=CoM_data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
CoM_model_1b = glmer(CoM_Next ~ zAbsDV + (zAbsDV | Participant), data=CoM_data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
CoM_model_2b = glmer(CoM_Next ~ zAbsDV + zConf + (zAbsDV + zConf | Participant), data=CoM_data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
CoM_model_3b = glmer(CoM_Next ~ zAbsDV + zConf + zRT + (zAbsDV + zConf + zRT | Participant),
data=CoM_data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
CoM_model_4b = glmer(CoM_Next ~ zAbsDV + zConf + zRT + zSV + (zAbsDV + zConf + zRT +
zSV | Participant), data=CoM_data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
CoM_model_5b = glmer(CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF + (zAbsDV + zConf + zRT +
zSV + zGSF | Participant), data=CoM_data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
CoM_model_6b = glmer(CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zConf + zRT +
zSV + zGSF + zAbsDDT | Participant), data=CoM_data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
CoM_model_7b = glmer(CoM_Next ~ zAbsDV + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zRT +
zSV + zGSF + zAbsDDT | Participant), data=CoM_data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
%%R
comparison3b =anova(CoM_emptyb, CoM_model_1b, CoM_model_2b,
CoM_model_3b, CoM_model_4b, CoM_model_5b,
CoM_model_6b, CoM_model_7b)
BIC3b = list(comparison3b$BIC)
%%R
comparison3b
Data: CoM_data_exp2 Models: CoM_emptyb: CoM_Next ~ 1 + (1 | Participant) CoM_model_1b: CoM_Next ~ zAbsDV + (zAbsDV | Participant) CoM_model_2b: CoM_Next ~ zAbsDV + zConf + (zAbsDV + zConf | Participant) CoM_model_3b: CoM_Next ~ zAbsDV + zConf + zRT + (zAbsDV + zConf + zRT | Participant) CoM_model_4b: CoM_Next ~ zAbsDV + zConf + zRT + zSV + (zAbsDV + zConf + zRT + CoM_model_4b: zSV | Participant) CoM_model_5b: CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF + (zAbsDV + zConf + CoM_model_5b: zRT + zSV + zGSF | Participant) CoM_model_7b: CoM_Next ~ zAbsDV + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zRT + CoM_model_7b: zSV + zGSF + zAbsDDT | Participant) CoM_model_6b: CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + CoM_model_6b: zConf + zRT + zSV + zGSF + zAbsDDT | Participant) Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq) CoM_emptyb 2 1817.4 1828.8 -906.68 1813.4 CoM_model_1b 5 1805.2 1833.8 -897.58 1795.2 18.2174 3 0.0003967 *** CoM_model_2b 9 1718.5 1770.2 -850.26 1700.5 94.6231 4 < 2.2e-16 *** CoM_model_3b 14 1683.2 1763.6 -827.62 1655.2 45.2789 5 1.273e-08 *** CoM_model_4b 20 1686.9 1801.7 -823.46 1646.9 8.3225 6 0.2154160 CoM_model_5b 27 1699.7 1854.6 -822.85 1645.7 1.2334 7 0.9901376 CoM_model_7b 27 1737.8 1892.7 -841.89 1683.8 0.0000 0 1.0000000 CoM_model_6b 35 1712.2 1913.0 -821.09 1642.2 41.6026 8 1.608e-06 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
%R -o BIC3b
BIC3b= np.array(BIC3b); CoM_Table['BIC'] = np.append(BIC3b[0][:6], (BIC3b[0][7], BIC3b[0][6]))
BIC_bar(CoM_Table.loc[1:, :].copy().reset_index(drop=True), title='')
plt.tight_layout()
#plt.savefig('../../figures/exp2_CoM_models.png', dpi=600)
transitivity_models = ['Empty', 'Model 1', 'Model 2', 'Model 3', 'Model 4', 'Model 5', 'Model 6', 'Model 7']
transitivity_formulas = ['Transitivity Violation ~ 1', 'Transitivity Violation ~ |Difference in Value|', 'Transitivity Violation ~ |Difference in Value| + Confidence',
'Transitivity Violation ~ |Difference in Value| + Confidence + Response Time',
'Transitivity Violation ~ |Difference in Value| + Confidence + Response Time + Summed Value',
'Transitivity Violation ~ |Difference in Value| + Confidence + Response Time + Summed Value + Gaze Shift Frequency',
'Transitivity Violation ~ |Difference in Value| + Confidence + Response Time + Summed Value + Gaze Shift Frequency + |Difference in Dwell Time|',
'Transitivity Violation ~ |Difference in Value| + Response Time + Summed Value + Gaze Shift Frequency + |Difference in Dwell Time|']
Transitivity_Table = pd.DataFrame([transitivity_models, transitivity_formulas])
Transitivity_Table = Transitivity_Table.transpose(); Transitivity_Table.columns = ['Models', 'Formulas']
pd.set_option('max_colwidth', 200)
Transitivity_Table
Models | Formulas | |
---|---|---|
0 | Empty | Transitivity Violation ~ 1 |
1 | Model 1 | Transitivity Violation ~ |Difference in Value| |
2 | Model 2 | Transitivity Violation ~ |Difference in Value| + Confidence |
3 | Model 3 | Transitivity Violation ~ |Difference in Value| + Confidence + Response Time |
4 | Model 4 | Transitivity Violation ~ |Difference in Value| + Confidence + Response Time + Summed Value |
5 | Model 5 | Transitivity Violation ~ |Difference in Value| + Confidence + Response Time + Summed Value + Gaze Shift Frequency |
6 | Model 6 | Transitivity Violation ~ |Difference in Value| + Confidence + Response Time + Summed Value + Gaze Shift Frequency + |Difference in Dwell Time| |
7 | Model 7 | Transitivity Violation ~ |Difference in Value| + Response Time + Summed Value + Gaze Shift Frequency + |Difference in Dwell Time| |
%%R
TV_empty = glmer(Transitivity_Violation ~ 1 + (1 | Participant), data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
TV_model_1 = glmer(Transitivity_Violation ~ zAbsDV + (zAbsDV | Participant), data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
TV_model_2 = glmer(Transitivity_Violation ~ zAbsDV + zConf + (zAbsDV + zConf | Participant), data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
TV_model_3 = glmer(Transitivity_Violation ~ zAbsDV + zConf + zRT + (zAbsDV + zConf + zRT | Participant),
data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
TV_model_4 = glmer(Transitivity_Violation ~ zAbsDV + zConf + zRT + zSV + (zAbsDV + zConf + zRT +
zSV | Participant), data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
TV_model_5 = glmer(Transitivity_Violation ~ zAbsDV + zConf + zRT + zSV + zGSF + (zAbsDV + zConf + zRT +
zSV + zGSF | Participant), data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
TV_model_6 = glmer(Transitivity_Violation ~ zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zConf + zRT +
zSV + zGSF + zAbsDDT | Participant), data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
TV_model_7 = glmer(Transitivity_Violation ~ zAbsDV + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zRT +
zSV + zGSF + zAbsDDT | Participant), data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
%%R
comparison4 =anova(TV_empty, TV_model_1, TV_model_2, TV_model_3, TV_model_4,
TV_model_5, TV_model_6, TV_model_7)
BIC4 = list(comparison4$BIC)
%%R
comparison4
Data: data_exp1 Models: TV_empty: Transitivity_Violation ~ 1 + (1 | Participant) TV_model_1: Transitivity_Violation ~ zAbsDV + (zAbsDV | Participant) TV_model_2: Transitivity_Violation ~ zAbsDV + zConf + (zAbsDV + zConf | Participant) TV_model_3: Transitivity_Violation ~ zAbsDV + zConf + zRT + (zAbsDV + zConf + TV_model_3: zRT | Participant) TV_model_4: Transitivity_Violation ~ zAbsDV + zConf + zRT + zSV + (zAbsDV + TV_model_4: zConf + zRT + zSV | Participant) TV_model_5: Transitivity_Violation ~ zAbsDV + zConf + zRT + zSV + zGSF + TV_model_5: (zAbsDV + zConf + zRT + zSV + zGSF | Participant) TV_model_7: Transitivity_Violation ~ zAbsDV + zRT + zSV + zGSF + zAbsDDT + TV_model_7: (zAbsDV + zRT + zSV + zGSF + zAbsDDT | Participant) TV_model_6: Transitivity_Violation ~ zAbsDV + zConf + zRT + zSV + zGSF + TV_model_6: zAbsDDT + (zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT | TV_model_6: Participant) Df AIC BIC logLik deviance Chisq Chi Df Pr(>Chisq) TV_empty 2 2473.9 2487.5 -1234.9 2469.9 TV_model_1 5 2246.8 2280.9 -1118.4 2236.8 233.0431 3 < 2.2e-16 *** TV_model_2 9 2096.1 2157.4 -1039.0 2078.1 158.7641 4 < 2.2e-16 *** TV_model_3 14 2082.3 2177.7 -1027.2 2054.3 23.7332 5 0.0002443 *** TV_model_4 20 2070.1 2206.3 -1015.0 2030.0 24.2774 6 0.0004643 *** TV_model_5 27 2077.3 2261.3 -1011.7 2023.3 6.7056 7 0.4601622 TV_model_7 27 2179.5 2363.4 -1062.7 2125.5 0.0000 0 1.0000000 TV_model_6 35 2084.1 2322.5 -1007.0 2014.0 111.4152 8 < 2.2e-16 *** --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
%R -o BIC4
BIC4 = np.array(BIC4); Transitivity_Table['BIC'] = np.append(BIC4[0][:6], (BIC4[0][7], BIC4[0][6]))
BIC_bar(Transitivity_Table.loc[1:, :].copy().reset_index(drop=True), title='')
plt.tight_layout()
#plt.savefig('../../figures/exp1_transitivity_models.png', dpi=600)
data_exp1.loc[:, ['zConf', 'zAbsDV', 'zRT', 'zGSF']].corr()
zConf | zAbsDV | zRT | zGSF | |
---|---|---|---|---|
zConf | 1.000000 | 0.437314 | -0.455816 | -0.322645 |
zAbsDV | 0.437314 | 1.000000 | -0.269632 | -0.193514 |
zRT | -0.455816 | -0.269632 | 1.000000 | 0.572728 |
zGSF | -0.322645 | -0.193514 | 0.572728 | 1.000000 |
data_exp2.loc[:, ['zConf', 'zAbsDV', 'zRT', 'zGSF']].corr()
zConf | zAbsDV | zRT | zGSF | |
---|---|---|---|---|
zConf | 1.000000 | 0.212417 | -0.444060 | -0.431986 |
zAbsDV | 0.212417 | 1.000000 | -0.131312 | -0.133585 |
zRT | -0.444060 | -0.131312 | 1.000000 | 0.635481 |
zGSF | -0.431986 | -0.133585 | 0.635481 | 1.000000 |
%%R
vv = vcov(main_CoM_model_exp1, corr=TRUE)
as(vv, "corMatrix")
7 x 7 Matrix of class "corMatrix" (Intercept) zAbsDV zConf zRT zSV (Intercept) 1.000000000 0.429840602 0.20420277 -0.09761350 -0.13859653 zAbsDV 0.429840602 1.000000000 -0.15526190 -0.00610580 -0.11937209 zConf 0.204202766 -0.155261896 1.00000000 0.20531833 -0.26646536 zRT -0.097613503 -0.006105800 0.20531833 1.00000000 -0.03065057 zSV -0.138596534 -0.119372089 -0.26646536 -0.03065057 1.00000000 zGSF 0.009599356 0.030073727 0.09021921 -0.63373865 -0.03739095 zAbsDDT 0.002797167 -0.005508631 -0.01888313 -0.61296073 -0.01131531 zGSF zAbsDDT (Intercept) 0.009599356 0.002797167 zAbsDV 0.030073727 -0.005508631 zConf 0.090219212 -0.018883130 zRT -0.633738646 -0.612960732 zSV -0.037390954 -0.011315311 zGSF 1.000000000 0.319095026 zAbsDDT 0.319095026 1.000000000
%%R
vif1 = vif.mer(main_CoM_model_exp1)
vif1
zAbsDV zConf zRT zSV zGSF zAbsDDT 1.064374 1.319821 2.860377 1.109448 1.890276 1.678277
%%R
vv = vcov(main_CoM_model_exp2, corr=TRUE)
as(vv, "corMatrix")
7 x 7 Matrix of class "corMatrix" (Intercept) zAbsDV zConf zRT zSV (Intercept) 1.00000000 0.11834115 0.24345349 -0.32637607 0.08367745 zAbsDV 0.11834115 1.00000000 -0.05460037 0.05674423 0.36299723 zConf 0.24345349 -0.05460037 1.00000000 0.16112476 -0.22178592 zRT -0.32637607 0.05674423 0.16112476 1.00000000 0.01364369 zSV 0.08367745 0.36299723 -0.22178592 0.01364369 1.00000000 zGSF 0.10985325 0.01075101 0.10879950 -0.52368620 0.14879346 zAbsDDT 0.07560671 -0.06499009 0.12483946 -0.35744122 -0.18603589 zGSF zAbsDDT (Intercept) 0.10985325 0.07560671 zAbsDV 0.01075101 -0.06499009 zConf 0.10879950 0.12483946 zRT -0.52368620 -0.35744122 zSV 0.14879346 -0.18603589 zGSF 1.00000000 0.14568653 zAbsDDT 0.14568653 1.00000000
%%R
vif2 = vif.mer(main_CoM_model_exp2)
vif2
zAbsDV zConf zRT zSV zGSF zAbsDDT 1.157089 1.213884 1.747731 1.308248 1.558046 1.228959
CoM_data_exp1['CoM_Next'] = CoM_data_exp1['CoM']
CoM_data_exp1b = CoM_data_exp1.loc[CoM_data_exp1['zRT']>0, :].copy()
CoM_data_exp2b = CoM_data_exp2.loc[CoM_data_exp2['zRT']>0, :].copy()
%R -i CoM_data_exp1b
%R -i CoM_data_exp2b
%%R
CoM_Slow_exp1 = glmer(CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF +
zAbsDDT + (zAbsDV + zConf + zRT + zSV + zGSF +
zAbsDDT | Participant), data=CoM_data_exp1b, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="L-BFGS-B")))
fix_CoM_Slow_exp1 <- fixef(CoM_Slow_exp1)
fix_se_CoM_Slow_exp1 <- sqrt(diag(vcov(CoM_Slow_exp1)))
names_CoM_Slow_exp1 <- names(fix_CoM_Slow_exp1)
summary(CoM_Slow_exp1)
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod] Family: binomial ( logit ) Formula: CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT | Participant) Data: CoM_data_exp1b Control: glmerControl(optimizer = "optimx", optCtrl = list(method = "L-BFGS-B")) AIC BIC logLik deviance df.resid 1084.2 1267.6 -507.1 1014.2 1362 Scaled residuals: Min 1Q Median 3Q Max -1.1009 -0.4225 -0.2814 -0.1300 5.6705 Random effects: Groups Name Variance Std.Dev. Corr Participant (Intercept) 0.59833 0.7735 zAbsDV 0.20378 0.4514 0.52 zConf 0.01522 0.1234 -0.45 0.23 zRT 0.37517 0.6125 -0.51 0.43 0.63 zSV 0.09791 0.3129 0.09 -0.48 -0.35 -0.75 zGSF 0.08130 0.2851 0.62 -0.19 -0.63 -0.93 0.82 zAbsDDT 0.01953 0.1398 -0.12 -0.73 -0.54 -0.70 0.90 0.68 Number of obs: 1397, groups: Participant, 28 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) -3.12332 0.27017 -11.561 < 2e-16 *** zAbsDV -1.18692 0.21330 -5.565 2.63e-08 *** zConf -0.46042 0.10485 -4.391 1.13e-05 *** zRT 0.14722 0.16749 0.879 0.37940 zSV 0.29801 0.10594 2.813 0.00491 ** zGSF -0.11565 0.12256 -0.944 0.34539 zAbsDDT 0.01986 0.07829 0.254 0.79973 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) zAbsDV zConf zRT zSV zGSF zAbsDV 0.644 zConf 0.144 -0.064 zRT -0.356 0.108 0.224 zSV -0.077 -0.180 -0.297 -0.343 zGSF 0.186 -0.009 0.029 -0.698 0.178 zAbsDDT -0.048 -0.127 -0.091 -0.549 0.202 0.419 convergence code: 0 Model failed to converge with max|grad| = 0.00186314 (tol = 0.001, component 1) Parameters or bounds appear to have different scalings. This can cause poor performance in optimization. It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.
%%R
CoM_Slow_exp2 = glmer(CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF +
zAbsDDT + (zAbsDV + zConf + zRT + zSV + zGSF +
zAbsDDT | Participant), data=CoM_data_exp2b, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
fix_CoM_Slow_exp2 <- fixef(CoM_Slow_exp2)
fix_se_CoM_Slow_exp2 <- sqrt(diag(vcov(CoM_Slow_exp2)))
names_CoM_Slow_exp2 <- names(fix_CoM_Slow_exp2)
summary(CoM_Slow_exp2)
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod] Family: binomial ( logit ) Formula: CoM_Next ~ zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT | Participant) Data: CoM_data_exp2b Control: glmerControl(optimizer = "optimx", optCtrl = list(method = "nlminb")) AIC BIC logLik deviance df.resid 1117.9 1292.4 -524.0 1047.9 1044 Scaled residuals: Min 1Q Median 3Q Max -1.1594 -0.5033 -0.3974 -0.2938 3.4336 Random effects: Groups Name Variance Std.Dev. Corr Participant (Intercept) 0.17847 0.4225 zAbsDV 0.12580 0.3547 -0.71 zConf 0.01737 0.1318 -0.81 0.37 zRT 0.08073 0.2841 -0.69 0.96 0.52 zSV 0.03915 0.1979 -0.12 0.47 -0.49 0.20 zGSF 0.01318 0.1148 0.76 -0.66 -0.89 -0.82 0.34 zAbsDDT 0.02005 0.1416 -0.20 0.09 0.68 0.37 -0.83 -0.75 Number of obs: 1079, groups: Participant, 24 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) -1.91303 0.16063 -11.909 < 2e-16 *** zAbsDV -0.04885 0.12345 -0.396 0.69233 zConf -0.30766 0.09573 -3.214 0.00131 ** zRT 0.24495 0.11673 2.098 0.03587 * zSV 0.20739 0.09287 2.233 0.02554 * zGSF 0.05140 0.09203 0.558 0.57651 zAbsDDT 0.02205 0.06701 0.329 0.74213 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) zAbsDV zConf zRT zSV zGSF zAbsDV -0.165 zConf 0.071 -0.012 zRT -0.566 0.300 0.208 zSV -0.084 0.263 -0.220 -0.019 zGSF 0.061 -0.095 0.052 -0.501 0.148 zAbsDDT -0.047 0.007 0.018 -0.195 -0.171 0.098 convergence code: 0 Parameters or bounds appear to have different scalings. This can cause poor performance in optimization. It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.
%R -o fix_CoM_Slow_exp1 -o fix_se_CoM_Slow_exp1 -o names_CoM_Slow_exp1
CoM_Slow_exp1_table = regtable(fix_CoM_Slow_exp1, fix_se_CoM_Slow_exp1, names_CoM_Slow_exp1)
CoM_Slow_exp1_table.columns = ['Intercept', '|DV|', 'Confidence', "RT", "SV", "GSF", "DDT"]
Coefpresplot(CoM_Slow_exp1_table, title='', ticklabsize=16, size='narrow', ymultiple=0.5, n_ET_predictors=2)
[i.set_color('#03719c') for i in plt.gca().get_xticklabels()[4:]]
#plt.savefig('../../figures/CoM_cut_slow_1.png', dpi=600, bbox_inches='tight')
[None, None]
%R -o fix_CoM_Slow_exp2 -o fix_se_CoM_Slow_exp2 -o names_CoM_Slow_exp2
CoM_Slow_exp2_table = regtable(fix_CoM_Slow_exp2, fix_se_CoM_Slow_exp2, names_CoM_Slow_exp2)
CoM_Slow_exp2_table.columns = ['Intercept', '|DV|', 'Confidence', "RT", "SV", "GSF", "DDT"]
Coefpresplot(CoM_Slow_exp2_table, title='', ticklabsize=16, size='narrow', ymultiple=0.5, n_ET_predictors=2)
[i.set_color('#03719c') for i in plt.gca().get_xticklabels()[4:]]
#plt.savefig('../../figures/CoM_cut_slow_1.png', dpi=600, bbox_inches='tight')
[None, None]
%%R
summary(CoM_model_7a)
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod] Family: binomial ( logit ) Formula: CoM_Next ~ zAbsDV + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zRT + zSV + zGSF + zAbsDDT | Participant) Data: CoM_data_exp1 Control: glmerControl(optimizer = "optimx", optCtrl = list(method = "nlminb")) AIC BIC logLik deviance df.resid 1643.7 1808.9 -794.9 1589.7 3333 Scaled residuals: Min 1Q Median 3Q Max -1.2137 -0.3081 -0.1751 -0.0821 7.8389 Random effects: Groups Name Variance Std.Dev. Corr Participant (Intercept) 0.57516 0.7584 zAbsDV 0.41771 0.6463 0.70 zRT 0.22430 0.4736 -0.32 0.30 zSV 0.07083 0.2661 0.09 0.09 -0.53 zGSF 0.08719 0.2953 0.72 0.16 -0.87 0.54 zAbsDDT 0.01193 0.1092 -0.31 -0.77 -0.45 0.19 0.22 Number of obs: 3360, groups: Participant, 28 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) -3.501363 0.205807 -17.013 < 2e-16 *** zAbsDV -1.453398 0.189180 -7.683 1.56e-14 *** zRT 0.426501 0.131055 3.254 0.00114 ** zSV 0.123784 0.085140 1.454 0.14598 zGSF -0.052592 0.109109 -0.482 0.62980 zAbsDDT -0.004632 0.071751 -0.065 0.94852 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) zAbsDV zRT zSV zGSF zAbsDV 0.743 zRT -0.248 0.138 zSV -0.003 -0.017 -0.211 zGSF 0.291 0.080 -0.767 0.163 zAbsDDT -0.066 -0.162 -0.504 0.031 0.311 convergence code: 0 Parameters or bounds appear to have different scalings. This can cause poor performance in optimization. It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.
%%R
summary(CoM_model_7b)
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod] Family: binomial ( logit ) Formula: CoM_Next ~ zAbsDV + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zRT + zSV + zGSF + zAbsDDT | Participant) Data: CoM_data_exp2 Control: glmerControl(optimizer = "optimx", optCtrl = list(method = "nlminb")) AIC BIC logLik deviance df.resid 1737.8 1892.7 -841.9 1683.8 2266 Scaled residuals: Min 1Q Median 3Q Max -2.2502 -0.4054 -0.3099 -0.2269 4.5264 Random effects: Groups Name Variance Std.Dev. Corr Participant (Intercept) 0.203446 0.45105 zAbsDV 0.058222 0.24129 0.10 zRT 0.040020 0.20005 -0.70 -0.13 zSV 0.036156 0.19015 0.22 0.74 0.22 zGSF 0.003744 0.06119 0.75 -0.03 -0.12 0.51 zAbsDDT 0.035406 0.18816 0.14 -0.03 -0.11 -0.30 -0.23 Number of obs: 2293, groups: Participant, 24 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) -2.21684 0.12342 -17.962 < 2e-16 *** zAbsDV -0.20052 0.09602 -2.088 0.0368 * zRT 0.48301 0.08964 5.388 7.11e-08 *** zSV 0.05764 0.07986 0.722 0.4705 zGSF 0.12401 0.07935 1.563 0.1181 zAbsDDT 0.00896 0.06954 0.129 0.8975 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) zAbsDV zRT zSV zGSF zAbsDV 0.141 zRT -0.442 0.002 zSV 0.093 0.357 0.004 zGSF 0.086 0.042 -0.562 0.168 zAbsDDT 0.079 -0.027 -0.332 -0.100 0.149 convergence code: 0 Parameters or bounds appear to have different scalings. This can cause poor performance in optimization. It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.
%%R
summary(TV_model_7)
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod] Family: binomial ( logit ) Formula: Transitivity_Violation ~ zAbsDV + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zRT + zSV + zGSF + zAbsDDT | Participant) Data: data_exp1 Control: glmerControl(optimizer = "optimx", optCtrl = list(method = "nlminb")) AIC BIC logLik deviance df.resid 2179.5 2363.4 -1062.7 2125.5 6693 Scaled residuals: Min 1Q Median 3Q Max -1.1109 -0.2294 -0.1447 -0.0783 10.9402 Random effects: Groups Name Variance Std.Dev. Corr Participant (Intercept) 0.37987 0.6163 zAbsDV 0.31806 0.5640 0.73 zRT 0.08746 0.2957 -0.02 0.40 zSV 0.09869 0.3141 -0.08 -0.09 -0.80 zGSF 0.02989 0.1729 0.76 0.97 0.33 -0.06 zAbsDDT 0.03484 0.1866 -0.57 -0.87 -0.73 0.51 -0.87 Number of obs: 6720, groups: Participant, 28 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) -3.95865 0.17018 -23.262 < 2e-16 *** zAbsDV -1.26836 0.16279 -7.791 6.63e-15 *** zRT 0.45565 0.10079 4.521 6.16e-06 *** zSV 0.06828 0.08513 0.802 0.423 zGSF -0.10925 0.08891 -1.229 0.219 zAbsDDT -0.04420 0.07490 -0.590 0.555 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) zAbsDV zRT zSV zGSF zAbsDV 0.750 zRT -0.084 0.170 zSV -0.051 -0.072 -0.307 zGSF 0.219 0.269 -0.482 -0.036 zAbsDDT -0.181 -0.285 -0.637 0.179 0.094 convergence code: 0 Parameters or bounds appear to have different scalings. This can cause poor performance in optimization. It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.
%%R
main_BDM_model_exp1 = glmer(BDM_viol ~ zAbsDV + zConf + zRT + zSV +
zGSF + zAbsDDT + (zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT | Participant),
data=data_exp1, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
fix_BDM_exp1 <- fixef(main_BDM_model_exp1)
fix_se_BDM_exp1 <- sqrt(diag(vcov(main_BDM_model_exp1)))
names_BDM_exp1 <- names(fix_BDM_exp1)
summary(main_BDM_model_exp1)
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod] Family: binomial ( logit ) Formula: BDM_viol ~ zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT | Participant) Data: data_exp1 Control: glmerControl(optimizer = "optimx", optCtrl = list(method = "nlminb")) AIC BIC logLik deviance df.resid 4174.2 4411.6 -2052.1 4104.2 6473 Scaled residuals: Min 1Q Median 3Q Max -2.4472 -0.4097 -0.1688 -0.0422 12.0976 Random effects: Groups Name Variance Std.Dev. Corr Participant (Intercept) 1.305074 1.14240 zAbsDV 0.376856 0.61389 0.93 zConf 0.116531 0.34137 0.39 0.17 zRT 0.004707 0.06861 0.83 0.72 0.59 zSV 0.103071 0.32105 0.24 0.28 -0.08 -0.31 zGSF 0.005266 0.07257 0.15 -0.07 0.68 0.14 0.24 zAbsDDT 0.008959 0.09465 -0.72 -0.75 -0.36 -0.34 -0.75 -0.26 Number of obs: 6508, groups: Participant, 28 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) -2.98441 0.23806 -12.536 < 2e-16 *** zAbsDV -1.83065 0.15536 -11.783 < 2e-16 *** zConf -0.48390 0.08493 -5.698 1.21e-08 *** zRT 0.20020 0.06577 3.044 0.00233 ** zSV 0.19997 0.07618 2.625 0.00867 ** zGSF -0.02061 0.05830 -0.354 0.72366 zAbsDDT -0.07074 0.05271 -1.342 0.17963 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) zAbsDV zConf zRT zSV zGSF zAbsDV 0.856 zConf 0.322 0.061 zRT 0.138 0.105 0.228 zSV 0.152 0.164 -0.149 -0.084 zGSF 0.038 0.001 0.156 -0.620 0.046 zAbsDDT -0.221 -0.195 -0.114 -0.592 -0.213 0.281 convergence code: 0 Parameters or bounds appear to have different scalings. This can cause poor performance in optimization. It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.
%%R
data_exp2['BDM_viol'] = 1 - data_exp2['Chose_Highest']
main_BDM_model_exp2 = glmer(BDM_viol ~ zAbsDV + zConf + zRT + zSV +
zGSF + zAbsDDT + (zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT | Participant),
data=data_exp2, family='binomial',
control=glmerControl(optimizer="optimx", optCtrl=list(method="nlminb")))
fix_BDM_exp2 <- fixef(main_BDM_model_exp2)
fix_se_BDM_exp2 <- sqrt(diag(vcov(main_BDM_model_exp2)))
names_BDM_exp2 <- names(fix_BDM_exp2)
summary(main_BDM_model_exp2)
Generalized linear mixed model fit by maximum likelihood (Laplace Approximation) [glmerMod] Family: binomial ( logit ) Formula: BDM_viol ~ zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT + (zAbsDV + zConf + zRT + zSV + zGSF + zAbsDDT | Participant) Data: data_exp2 Control: glmerControl(optimizer = "optimx", optCtrl = list(method = "nlminb")) AIC BIC logLik deviance df.resid 4055.8 4270.8 -1992.9 3985.8 3408 Scaled residuals: Min 1Q Median 3Q Max -2.2783 -0.7263 -0.4072 0.9106 3.1786 Random effects: Groups Name Variance Std.Dev. Corr Participant (Intercept) 0.551354 0.74253 zAbsDV 0.192045 0.43823 0.70 zConf 0.033486 0.18299 0.63 0.21 zRT 0.015951 0.12630 -0.66 -0.37 -0.92 zSV 0.160768 0.40096 0.08 0.40 -0.04 0.26 zGSF 0.006186 0.07865 0.29 -0.44 0.35 -0.29 -0.64 zAbsDDT 0.019437 0.13942 -0.20 -0.76 0.14 0.18 -0.05 0.63 Number of obs: 3443, groups: Participant, 24 Fixed effects: Estimate Std. Error z value Pr(>|z|) (Intercept) -0.82299 0.15895 -5.178 2.25e-07 *** zAbsDV -0.41505 0.10494 -3.955 7.65e-05 *** zConf -0.44567 0.06393 -6.971 3.15e-12 *** zRT 0.14084 0.06390 2.204 0.0275 * zSV 0.05175 0.09377 0.552 0.5811 zGSF 0.01033 0.05735 0.180 0.8571 zAbsDDT -0.06430 0.05160 -1.246 0.2128 --- Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1 Correlation of Fixed Effects: (Intr) zAbsDV zConf zRT zSV zGSF zAbsDV 0.626 zConf 0.394 0.070 zRT -0.261 -0.122 -0.071 zSV 0.071 0.359 -0.128 0.057 zGSF 0.078 -0.099 0.174 -0.568 -0.121 zAbsDDT -0.100 -0.372 0.058 -0.252 -0.044 0.270 convergence code: 1 Parameters or bounds appear to have different scalings. This can cause poor performance in optimization. It is important for derivative free methods like BOBYQA, UOBYQA, NEWUOA.
%R -o fix_BDM_exp1 -o fix_se_BDM_exp1 -o names_BDM_exp1
BDM_table = regtable(fix_BDM_exp1, fix_se_BDM_exp1, names_BDM_exp1)
BDM_table.columns = ['Intercept', '|DV|', 'Confidence', 'RT', 'SV', 'GSF', '|DDT|']
Coefpresplot(BDM_table, title='', ticklabsize=16, size='narrow', ymultiple=0.5, n_ET_predictors=2)
[i.set_color('#03719c') for i in plt.gca().get_xticklabels()[4:]]
#plt.savefig('../../figures/exp1_BV.png', bbox_inches='tight', dpi=600)
[None, None]
%R -o fix_BDM_exp2 -o fix_se_BDM_exp2 -o names_BDM_exp2
BDM_table2 = regtable(fix_BDM_exp2, fix_se_BDM_exp2, names_BDM_exp2)
BDM_table2.columns = ['Intercept', '|DV|', 'Confidence', 'RT', 'SV', 'GSF', '|DDT|']
Coefpresplot(BDM_table2, title='', ticklabsize=16, size='narrow', ymultiple=0.5, n_ET_predictors=2)
[i.set_color('#03719c') for i in plt.gca().get_xticklabels()[4:]]
#plt.savefig('../../figures/exp1_BV.png', bbox_inches='tight', dpi=600)
[None, None]
import numpy as np
import pandas as pd
from sklearn import linear_model # packages for the logistic regression function to plot the logistic regression
from sklearn.linear_model import LogisticRegression # packages for the logistic regression function to plot the logistic regression
from scipy import stats
from scipy.stats.stats import pearsonr # Pearson's correlation
from pandas.core.frame import DataFrame as DF
from copy import copy as copy
import operator as operator
import pylab
# Show graphs in Notebook
%matplotlib inline
# Plotting tools
import matplotlib.pyplot as plt
import matplotlib.gridspec as gridspec
import matplotlib.patches as mpatches
import seaborn as sns
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
%pylab inline
figsize(15, 15);
# Set up interface with R
import rpy2
%load_ext rpy2.ipython
# Make it easy to set and find values in a multi-index DF
idx = pd.IndexSlice
/Users/Tomas/anaconda/lib/python2.7/site-packages/matplotlib/__init__.py:872: UserWarning: axes.color_cycle is deprecated and replaced with axes.prop_cycle; please use the latter. warnings.warn(self.msg_depr % (key, alt_key)) WARNING: pylab import has clobbered these variables: ['pylab', 'copy'] `%matplotlib` prevents importing * from pylab and numpy
Populating the interactive namespace from numpy and matplotlib
%%R
library(lme4)
library(car)
library(gdata)
library(optimx)
library(MASS)
library(mlogit)
library(pbkrtest)
/Users/Tomas/anaconda/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: Loading required package: Matrix res = super(Function, self).__call__(*new_args, **new_kwargs) /Users/Tomas/anaconda/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: gdata: read.xls support for 'XLS' (Excel 97-2004) files ENABLED. res = super(Function, self).__call__(*new_args, **new_kwargs) /Users/Tomas/anaconda/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: res = super(Function, self).__call__(*new_args, **new_kwargs) /Users/Tomas/anaconda/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: gdata: read.xls support for 'XLSX' (Excel 2007+) files ENABLED. res = super(Function, self).__call__(*new_args, **new_kwargs) /Users/Tomas/anaconda/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: Attaching package: ‘gdata’ res = super(Function, self).__call__(*new_args, **new_kwargs) /Users/Tomas/anaconda/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: The following object is masked from ‘package:stats’: nobs res = super(Function, self).__call__(*new_args, **new_kwargs) /Users/Tomas/anaconda/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: The following object is masked from ‘package:utils’: object.size res = super(Function, self).__call__(*new_args, **new_kwargs) /Users/Tomas/anaconda/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: Loading required package: Formula res = super(Function, self).__call__(*new_args, **new_kwargs) /Users/Tomas/anaconda/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: Loading required package: maxLik res = super(Function, self).__call__(*new_args, **new_kwargs) /Users/Tomas/anaconda/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: Loading required package: miscTools res = super(Function, self).__call__(*new_args, **new_kwargs) /Users/Tomas/anaconda/lib/python2.7/site-packages/rpy2/robjects/functions.py:106: UserWarning: Please cite the 'maxLik' package as: Henningsen, Arne and Toomet, Ott (2011). maxLik: A package for maximum likelihood estimation in R. Computational Statistics 26(3), 443-458. DOI 10.1007/s00180-010-0217-1. If you have questions, suggestions, or comments regarding the 'maxLik' package, please use a forum or 'tracker' at maxLik's R-Forge site: https://r-forge.r-project.org/projects/maxlik/ res = super(Function, self).__call__(*new_args, **new_kwargs)
ten_aqua= sns.color_palette('GnBu', 10)
sns.palplot(ten_aqua[2:10])
data_exp1 = pd.read_csv('../data/exp1_main_data.csv') # The main data file for the first
# experiment
par_data_exp1 = pd.read_csv('../data/exp1_participantwise_data.csv', index_col=0) # The data file for examining individual
# differences for the first experiment
data_exp2 = pd.read_csv('../data/exp2_main_data.csv') # The main data file for the second
# experiment
par_data_exp2 = pd.read_csv('../data/exp2_participantwise_data.csv', index_col=0) # The data file for examining individual
# differences
CoM_data_exp1 = data_exp1.loc[data_exp1['Presentation']==1, :]
CoM_data_exp2 = data_exp2.loc[data_exp2['Block']!=3, :]
%R -i CoM_data_exp1
%R -i CoM_data_exp2
par_data_exp1['zMeta_Conf'] = (par_data_exp1['Meta_Conf'] -
par_data_exp1['Meta_Conf'].mean())/par_data_exp1['Meta_Conf'].std()
par_data_exp1['zConf_Predicting_CoM'] = (par_data_exp1['Pref_Rev_Conf'] -
par_data_exp1['Pref_Rev_Conf'].mean())/par_data_exp1['Pref_Rev_Conf'].std()
par_data_exp1['Experiment'] = 1
par_data_exp2['zMeta_Conf'] = (par_data_exp2['Meta_Accuracy_Multinomial'] -
par_data_exp2['Meta_Accuracy_Multinomial'].mean())/par_data_exp2['Meta_Accuracy_Multinomial'].std()
par_data_exp2['zConf_Predicting_CoM'] = (par_data_exp2['Conf_Predicting_CoM'] -
par_data_exp2['Conf_Predicting_CoM'].mean())/par_data_exp2['Conf_Predicting_CoM'].std()
par_data_exp2['Experiment'] = 2
two_samples = pd.concat([par_data_exp1[['zMeta_Conf', 'zConf_Predicting_CoM', 'Experiment']],
par_data_exp2[['zMeta_Conf', 'zConf_Predicting_CoM', 'Experiment']]], ignore_index=True)
# Load the data
ConfHeat_exp1 = pd.read_csv('../Data/exp1_heatmaps/conf_heatmap_raw.csv', index_col=0)
# Flip to get a good viewing angle
Z_Conf_Heat_exp1 = np.fliplr(np.flipud(ConfHeat_exp1.values))
# Normalise between 0 and 1
Z_Conf_Heat_exp1 = Z_Conf_Heat_exp1 + np.abs(Z_Conf_Heat_exp1.min())
Z_Conf_Heat_exp1 = Z_Conf_Heat_exp1/Z_Conf_Heat_exp1.max()
# Load the data
SwitchHeat_exp1 = pd.read_csv('../Data/exp1_heatmaps/gsf_heatmap_raw.csv', index_col=0)
# Flip to get a good viewing angle
Z_Switch_Heat_exp1 = np.fliplr(np.flipud(SwitchHeat_exp1.values))
# Normalise between 0 and 1
Z_Switch_Heat_exp1 = Z_Switch_Heat_exp1 + np.abs(Z_Switch_Heat_exp1.min())
Z_Switch_Heat_exp1 = Z_Switch_Heat_exp1/Z_Switch_Heat_exp1.max()
# Load the data
ConfHeat_exp2 = pd.read_csv('../Data/exp2_heatmaps/conf_heatmap_raw.csv', index_col=0)
# Flip to get a good viewing angle
Z_Conf_Heat_exp2 = np.fliplr(np.flipud(ConfHeat_exp2.values))
# Normalise between 0 and 1
Z_Conf_Heat_exp2= Z_Conf_Heat_exp2 + np.abs(Z_Conf_Heat_exp2.min())
Z_Conf_Heat_exp2 = Z_Conf_Heat_exp2/Z_Conf_Heat_exp2.max()
# Load the data
SwitchHeat_exp2 = pd.read_csv('../Data/exp2_heatmaps/gsf_heatmap_raw.csv', index_col=0)
# Flip to get a good viewing angle
Z_Switch_Heat_exp2 = np.fliplr(np.flipud(SwitchHeat_exp2.values))
# Normalise between 0 and 1
Z_Switch_Heat_exp2 = Z_Switch_Heat_exp2 + np.abs(Z_Switch_Heat_exp2.min())
Z_Switch_Heat_exp2 = Z_Switch_Heat_exp2/Z_Switch_Heat_exp2.max()
TransHeat_Norm = pd.read_csv('../Data/transitivity_heatmaps/TransHeat_Full_Norm.csv', index_col='Left Items'); TransHeat_Norm.columns.names= ['Right Items']
TransHeatHC_Norm = pd.read_csv('../Data/transitivity_heatmaps/TransHeat_High_Norm.csv' , index_col='Left Items'); TransHeatHC_Norm.columns.names= ['Right Items']
TransHeatLC_Norm = pd.read_csv('../Data/transitivity_heatmaps/TransHeat_Low_Norm.csv' , index_col='Left Items') ; TransHeatLC_Norm.columns.names= ['Right Items']
TransHeat_Norm = TransHeat_Norm.iloc[::-1, ::-1]
TransHeatHC_Norm = TransHeatHC_Norm.iloc[::-1, ::-1]
TransHeatLC_Norm = TransHeatLC_Norm.iloc[::-1, ::-1]
%R -i data_exp1
%R -i data_exp2
def BIC_bar(data, title='title'):
# set figure-level properties
sns.set(font_scale=2, style='white')
fig = figure(figsize=(8,8))
fig.add_subplot(111)
top= subplot(111)
# determine variables
BIC = data['BIC'].get_values()
N = len(data['BIC'])
ylims = [data['BIC'].min()-(data['BIC'].max()/100), data['BIC'].max()+(data['BIC'].max()/100)]
ind = np.arange(N) # the x locations for the groups
width = 0.5 # the width of the bars
# draw the bars
rects1 = top.bar(ind, BIC, width, color='#5b7c99')
# add some text for labels, title and axes ticks
top.set_ylabel('BIC Scores')
top.set_title(title)
top.set_xticks(ind+width/2)
top.set_xticklabels(data['Models'], rotation='vertical')
# set the axis limits
top.set_ylim(ylims)
top.set_xlim([-0.5, N])
# hide spines
top.spines['top'].set_visible(False)
top.spines['right'].set_visible(False)
def logisticplot_all (moderator, modhigh, modlow, data, xaxis='zDV', yaxis='G_choice', ylab='P(Chose Reference Item)', xlab='DV (Z-score)',
modhighcol='#000000', modlowcol='#AAAAAA', title='empty', parvar='SubNo'):
sns.set(font_scale=1.5, style='white')
fig = figure(figsize=(8,7))
fig.set_facecolor('white')
# defining the sigmoid function
def model(x):
y = 1 / (1 + np.exp(-x))
return y
sub = plt.subplot()
#run the classifier
clf = linear_model.LogisticRegression(C=1e5)
# Paula used these dictionaries to store the values of the predictive lines for all the participants.
logit_low = {}
logit_high = {}
# I think this defines the problem space
X_test = np.linspace(-5,10,300)
# fitting the predictive logistic model for the low_confidence trials, for a participant specified by x
# first I specify the value difference right - left, then I specify the choices, left or right
clf.fit(data.loc[data[(data[moderator]==0)].index, xaxis][:, np.newaxis],
data.loc[data[(data[moderator]==0)].index, yaxis])
logit_low = model(X_test*clf.coef_ + clf.intercept_).ravel()
# fitting the predictive logistic model for the high_confidence trials, for a participant specified by x
# first I specify the value difference right - left, then I specify the choices, left or right
clf.fit(data.loc[data[(data[moderator]==1)].index, xaxis][:, np.newaxis],
data.loc[data[(data[moderator]==1)].index, yaxis])
logit_high = model(X_test * clf.coef_ + clf.intercept_).ravel()
#Plotting the predictive lines
line_high = sub.plot(X_test, logit_high, color=modhighcol, linewidth=5, label=modhigh, zorder=6)
line_low = sub.plot(X_test, logit_low, color=modlowcol, linewidth=5, label=modlow, zorder=5)
#Plotting the binned data
data['DVBin2'] = data.groupby(parvar).apply(parsplit, input=xaxis, quantiles=4).values
# determine the x coordinates
x_cords= data.groupby('DVBin2')[xaxis].mean()
# determine low y coordinates
y_cords_low = data.loc[(data[moderator]==0), :].groupby('DVBin2')[yaxis].mean().values
# determine low y standard errors
test = pd.DataFrame(data.loc[(data[moderator]==0), :].groupby(['DVBin2', parvar])[yaxis].mean()).reset_index()
y_low_error = test.groupby('DVBin2')[yaxis].std()/np.sqrt(len(test[parvar].unique()))
# determine high y coordinates
y_cords_high = data.loc[(data[moderator]==1), :].groupby('DVBin2')[yaxis].mean().values
# determine high y standard errors
test2 = pd.DataFrame(data.loc[data[moderator]==1, :].groupby(['DVBin2', parvar])[yaxis].mean()).reset_index()
y_high_error = test2.groupby('DVBin2')[yaxis].std()/np.sqrt(len(test[parvar].unique()))
# plot the low points
plt.scatter(x_cords, y_cords_low, c=modlowcol, marker='D', s=60, zorder=1)
# plot low error bars
plt.errorbar(x_cords, y_cords_low, yerr=y_low_error, fmt='o', zorder=3, c=modlowcol)
# plot the high points
plt.scatter(x_cords, y_cords_high, c=modhighcol, marker='o', s=60, zorder=2)
# plot high error bars
plt.errorbar(x_cords, y_cords_high, yerr=y_high_error, fmt='o', zorder=4, c=modhighcol)
# Set Labels
sub.set_ylabel(ylab, fontsize=30)
sub.set_xlabel(xlab, fontsize=30)
# Set Ticks
sub.set_xticks((-5,-3,-1,1,3,5))
sub.set_yticks((0,0.25,0.5,0.75,1))
sub.tick_params(axis='both', which='major', labelsize=20)
# Set Limits
sub.set_ylim(-0.01, 1.01)
sub.set_xlim(-5, 5)
# Set Title
if title == 'empty':
sub.set_title('')
else:
sub.set_title(title)
sub.legend(loc=2, prop={'size':20})
sns.despine()
def parsplit(DF, input, quantiles):
qvalues = pd.qcut(DF[input], quantiles, labels = range(1, quantiles+1))
return qvalues
def regtable(fix, fix_se, names):
fixed_betas = DF(np.array(fix)); fixed_betas = fixed_betas.transpose(); fixed_betas.columns = names
fixed_betas.loc[1] = np.array(fix_se)
fixed_betas.loc[2] = fixed_betas.loc[0] - (fixed_betas.loc[1]*1.96)
fixed_betas.loc[3] = fixed_betas.loc[0] + (fixed_betas.loc[1]*1.96)
fixed_betas.index = ['coefficient', 'se', 'CImin', 'CImax']
return fixed_betas
def Coefpresplot(regtable, intercept=False, title='Regression Coefficients', size='big', ylimits=(), ymultiple=0.5, ticklabsize=25, n_ET_predictors = 0):
# Import itertools so that we can iterate through the colours
import itertools
# Import locators so that we can tidy up the yaxis
from matplotlib.ticker import MultipleLocator, FormatStrFormatter
# rounding function to get edges to even 0.5 values
def round_to(n, precision):
correction = 0.5 if n >= 0 else -0.5
return int( n/precision+correction ) * precision
def round_to_5(n):
return round_to(n, 0.5)
# Set seaborn style for the plot
sns.set(style='white')
# Generate the figure
if size=='big':
fig = plt.figure(figsize=[20,8])
elif size=='long':
fig = plt.figure(figsize=[20,4])
elif size=='narrow':
fig = plt.figure(figsize=[10,4])
fig.suptitle(title, fontsize=30)
gs = GridSpec(1,1,bottom=0.18,left=0.18,right=0.82)
ax = fig.add_subplot(gs[0,0])
# Set axis limits based on whether to include the intercept or not
if intercept == True:
XLim = (0.75, len(regtable.columns) + 0.25)
YLim = (round_to_5(regtable.loc['CImin', :].min()-0.1), round_to_5(regtable.loc['CImax', :].max()+0.2))
else:
XLim = (0.75, len(regtable.columns) - 0.75)
YLim = (round_to_5(regtable.loc['CImin', regtable.columns[1]:].min()-0.2), round_to_5(regtable.loc['CImax', regtable.columns[1]:].max()+0.2))
if ylimits != ():
YLim = ylimits
ax.set_xlim(XLim)
ax.set_ylim(YLim)
# Draw a line through the 0-value on the y-axis
line = ax.plot(XLim, [0, 0], color='black', ls='--', alpha = 0.5, lw=3)
# If intercept is true, plot the coefficient for the intercept
if intercept == True:
Coefficients = regtable.columns
else:
Coefficients = regtable.columns[1:]
# Determine the colours for the coefficients based on the n_ET_variable
n_predictors = len(Coefficients)
n_non_ET_predictors = n_predictors - n_ET_predictors
colourlist = ['#000000'] * n_non_ET_predictors + ['#03719c'] * n_ET_predictors
# Plot all the coefficients with 95% CI
position = 0
for Coefficient in Coefficients:
position += 1
ax.plot(position, regtable.loc['coefficient', Coefficient], marker='o', ms=8, color=colourlist[position-1],)
ax.errorbar(position, regtable.loc['coefficient', Coefficient],
yerr=regtable.loc['se', Coefficient]*1.96, lw=2, color=colourlist[position-1])
# Setting the x-axis major tick's location
ax.set_xticks(range(1, position+1))
# set the y-axis major tick position
ax.yaxis.set_major_locator(MultipleLocator(ymultiple))
# Setting the x-axis major tick's label
if intercept == True:
ax.set_xticklabels(regtable.columns, rotation=40)
else:
ax.set_xticklabels(regtable.columns[1:], rotation=40)
ax.tick_params(axis='both', which='major', labelsize=ticklabsize)
ax.set_ylabel('Fixed Effects Coefficients', fontsize=18)
# Autoformats the ticklabels for the xaxis
fig.autofmt_xdate()
sns.despine()
%%R
vif.mer <- function (fit) {
## adapted from rms::vif
v <- vcov(fit)
nam <- names(fixef(fit))
## exclude intercepts
ns = 0
v <- v[-(1:ns), -(1:ns), drop = FALSE]
nam <- nam[-(1:ns)]
d <- diag(v)^0.5
v <- diag(solve(v/(d %o% d)))
names(v) <- nam
v
}