forked from anne-urai/2019_Urai_choice-history-ddm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
plot_posteriors.m
132 lines (107 loc) · 5.08 KB
/
plot_posteriors.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
function plot_posteriors
% Code to fit the history-dependent drift diffusion models as described in
% Urai AE, de Gee JW, Tsetsos K, Donner TH (2019) Choice history biases subsequent evidence accumulation. eLife, in press.
%
% MIT License
% Copyright (c) Anne Urai, 2019
% anne.urai@gmail.com
addpath(genpath('~/code/Tools'));
warning off; close all;
global mypath datasets datasetnames colors
colors2 = cbrewer('qual', 'Set2', length(datasets));
% ========================================== %
% STARTING POINT POSTERIORS
% ========================================== %
close; subplot(3,3,1); hold on;
plot([1 6], [0 0], 'k-', 'linewidth', 0.5);
for d = 1:length(datasets),
dat = readtable(sprintf('%s/%s/stimcoding_dc_z_prevresp/group_traces.csv', mypath, datasets{d}));
difference = dat.z_trans_1_ - dat.z_trans__1_;
violinPlot_distribution(d, difference, colors2(d, :));
legtext{d} = cat(2, datasetnames{d}{1}, ' ', datasetnames{d}{2});
pval = posteriorpval(dat.z_trans_1_, dat.z_trans__1_);
if pval < 0.001,
text(d+0.1, -0.5, sprintf('p < 0.001'), ...
'fontangle', 'italic', 'fontsize', 4, 'rotation', -30);
set(gca, 'xcolor', 'k', 'ycolor', 'k');
else
text(d+0.1, -0.5, sprintf('p = %.3f', pval), ...
'fontangle', 'italic', 'fontsize', 4, 'rotation', -30);
set(gca, 'xcolor', 'k', 'ycolor', 'k');
end
end
set(gca, 'xtick', 1:length(datasets), 'xticklabel', legtext, 'xticklabelrotation', -30, 'xcolor', 'k');
ylabel({'History shift in z'}, 'color', colors(1, :));
axis tight; offsetAxes;
tightfig;
print(gcf, '-dpdf', sprintf('~/Data/serialHDDM/bias_posteriors_startingpoint.pdf'));
% ========================================== %
% DRIFT BIAS POSTERIORS
% ========================================== %
close; subplot(3,3,1); hold on;
plot([1 6], [0 0], 'k-', 'linewidth', 0.5);
for d = 1:length(datasets),
dat = readtable(sprintf('%s/%s/stimcoding_dc_z_prevresp/group_traces.csv', mypath, datasets{d}));
disp(datasets{d});
difference = dat.dc_1_ - dat.dc__1_;
violinPlot_distribution(d, difference, colors2(d, :));
legtext{d} = cat(2, datasetnames{d}{1}, ' ', datasetnames{d}{2});
pval = posteriorpval(dat.dc_1_, dat.dc__1_);
if pval < 0.001,
text(d+0.1, -0.3, sprintf('p < 0.001'), ...
'fontangle', 'italic', 'fontsize', 4, 'rotation', -30);
set(gca, 'xcolor', 'k', 'ycolor', 'k');
else
text(d+0.1, -0.3, sprintf('p = %.3f', pval), ...
'fontangle', 'italic', 'fontsize', 4, 'rotation', -30);
set(gca, 'xcolor', 'k', 'ycolor', 'k');
end
end
set(gca, 'xtick', 1:length(datasets), 'xticklabel', legtext, 'xticklabelrotation', -30, 'xcolor', 'k');
ylabel({'History shift in v_{bias}'}, 'color', colors(2, :));
axis tight; offsetAxes;
tightfig;
print(gcf, '-dpdf', sprintf('~/Data/serialHDDM/bias_posteriors_driftbias.pdf'));
% ========================================== %
% STARTING POINT POSTERIORS - error vs. correct
% ========================================== %
close; subplot(3,3,1); hold on;
plot([1 6], [0 0], 'k-', 'linewidth', 0.5);
for d = 1:length(datasets),
disp(datasets{d});
dat = readtable(sprintf('%s/%s/stimcoding_dc_z_prevcorrect/group_traces.csv', mypath, datasets{d}));
difference = (dat.z_trans_1_1_ - dat.z_trans_1__1_) - (dat.z_trans_0_1_ - dat.z_trans_0__1_);
violinPlot_distribution(d, difference, colors2(d, :));
legtext{d} = cat(2, datasetnames{d}{1}, ' ', datasetnames{d}{2});
pval = posteriorpval((dat.z_trans_1_1_ - dat.z_trans_1__1_), (dat.z_trans_0_1_ - dat.z_trans_0__1_));
text(d+0.1, -0.3, sprintf('p = %.3f', pval), ...
'fontangle', 'italic', 'fontsize', 4, 'rotation', -30);
set(gca, 'xcolor', 'k', 'ycolor', 'k');
end
set(gca, 'xtick', 1:length(datasets), 'xticklabel', legtext, 'xticklabelrotation', -30, 'xcolor', 'k');
ylabel({'History shift in z'; 'after correct - error'});
axis tight; offsetAxes;
tightfig;
print(gcf, '-dpdf', sprintf('~/Data/serialHDDM/bias_posteriors_startingpoint_outcome.pdf'));
% ========================================== %
% DRIFT BIAS POSTERIORS - error vs. correct
% ========================================== %
close; subplot(3,3,1); hold on;
plot([1 6], [0 0], 'k-', 'linewidth', 0.5);
for d = 1:length(datasets),
dat = readtable(sprintf('%s/%s/stimcoding_dc_z_prevcorrect/group_traces.csv', mypath, datasets{d}));
disp(datasets{d});
difference = (dat.dc_1_1_ - dat.dc_1__1_) - (dat.dc_0_1_ - dat.dc_0__1_) ;
violinPlot_distribution(d, difference, colors2(d, :));
legtext{d} = cat(2, datasetnames{d}{1}, ' ', datasetnames{d}{2});
pval = posteriorpval((dat.dc_1_1_ - dat.dc_1__1_), (dat.dc_0_1_ - dat.dc_0__1_));
text(d+0.1, -1, sprintf('p = %.3f', pval), ...
'fontangle', 'italic', 'fontsize', 4, 'rotation', -30);
set(gca, 'xcolor', 'k', 'ycolor', 'k');
end
set(gca, 'xtick', 1:length(datasets), 'xticklabel', legtext, 'xticklabelrotation', -30, 'xcolor', 'k');
ylabel({'History shift in v_{bias}'; 'after correct - error'});
axis tight; offsetAxes;
tightfig;
print(gcf, '-dpdf', sprintf('~/Data/serialHDDM/bias_posteriors_driftbias_outcome.pdf'));
end