-
Notifications
You must be signed in to change notification settings - Fork 4
/
kostis_all_AICs.m
163 lines (138 loc) · 6.36 KB
/
kostis_all_AICs.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
function kostis_all_AICs
% 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
% ============================================ %
% AIC COMPARISON BETWEEN ALL MODELS
% ============================================ %
global mypath colors
cols1 = cbrewer('qual', 'Set1', 8);
cols2 = cbrewer('qual', 'Dark2', 8);
colors = [colors; cols1(2, :); cols2(6, :); nanmean([cols1(2, :); cols2(6, :)]); colors(1:3, :); cols2([5 3 4], :)];
% entry point: DDM, DDM-collapsingBounds, ddm-stimOnsetAccumulation
% OU-stimOnsetAccumulation, OU-stimOnsetAccumulation-collapsingBounds
% results = readtable('/Users/urai/Data/HDDM/summary/Anke_MEG_transition/allindividualresults_kostis.csv');
results = readtable(sprintf('%s/summary/%s/allindividualresults_kostis.csv', mypath, 'Anke_MEG_transition'));
% baselineModel = results.ddmK_vanilla_aic;
% ddmK = normal DDM, with ramping
% ddmColl = collapsing bounds
% ddmDColl = collapsing bounds, accumulation from stimulus onset
% ouK = O-U, accumulation from stimulus offset
% ouD = O-U, accumulation from stimulus onset
% ouDColl = O-U with collapsing bounds, accumulation from stimulus onset
model(1).data = [results.ddmK_z_aic results.ddmK_dc_aic results.ddmK_dcz_aic];
model(1).vanilla = results.ddmK_vanilla_aic;
model(1).name = {'1. Standard' 'DDM'};
model(1).ticklabels = {'z', 'v_{bias}', 'z+v_{bias}'};
model(1).colors = [colors; mean(colors([1 2], :))];
model(1).basevalue = unique(results.ddmK_vanilla_aic);
model(1).ylim = [-650 0];
model(1).subplot = 1;
model(end+1).data = [ results.ddmK_dc_aic results.ddmK_rp_aic results.ddmK_rp2_aic];
model(end).vanilla = results.ddmK_vanilla_aic;
model(end).name = {'2. DDM', 'dynamic v_{bias}'};
model(end).ticklabels = {'constant v_{bias}', 'ramp', 'constant+ramp'};
cols1 = cbrewer('qual', 'Set1', 8);
cols2 = cbrewer('qual', 'Dark2', 8);
model(end).colors = [cols1(2, :); cols2(6, :); nanmean([cols1(2, :); cols2(6, :)])];
model(end).basevalue = unique(results.ddmK_vanilla_aic);
model(end).ylim = [-650 0];
model(end).subplot = 2;
% model(end+1).data = [ results.ddmD_dc_aic results.ddmD_rp_aic results.ddmD_rp2_aic];
% model(end).vanilla = results.ddmD_vanilla_aic;
% model(end).name = {'2b. Dynamic DDM', 'drift bias'};
% model(end).ticklabels = {'constant v_{bias}', 'ramp', 'constant+ramp'};
% cols1 = cbrewer('qual', 'Set1', 8);
% cols2 = cbrewer('qual', 'Dark2', 8);
% model(end).colors = [cols1(2, :); cols2(6, :); nanmean([cols1(2, :); cols2(6, :)])];
% model(end).basevalue = unique(results.ddmD_vanilla_aic);
% model(end).ylim = [-8000 0];
% model(end).subplot = 4;
model(end+1).data = [results.ddmDColl_z_aic results.ddmDColl_dc_aic results.ddmDColl_dcz_aic];
model(end).vanilla = unique(results.ddmD_vanilla_aic)-6000;
model(end).name = {'3. Dynamic DDM', 'collapsing bounds'};
model(end).ticklabels = {'z', 'v_{bias}', 'z+v_{bias}'};
model(end).colors = [colors; mean(colors([1 2], :))];
model(end).basevalue = unique(results.ddmD_vanilla_aic);
model(end).ylim = [-8000 -6000];
model(end).subplot = 4;
% model(end+1).data = [results.ouD_sp_aic results.ouD_input_aic results.ouD_lambda_aic];
% model(end).vanilla = results.ddmK_vanilla_aic;
% model(end).name = {'4. Leaky' 'accumulator'};
% model(end).ticklabels = {'starting point bias', 'input bias', '\lambda bias'};
% model(end).colors = [cols2([5 3 4], :)];
% model(end).basevalue = unique(results.ddmD_vanilla_aic);
% model(end).ylim = [-8000 0];
% model(end).subplot = 5;
model(end+1).data = [results.ouDColl_sp_aic results.ouDColl_input_aic results.ouDColl_lambda_aic];
model(end).vanilla = unique(results.ddmD_vanilla_aic)-6000;
model(end).name = {'4. Leaky accumulator' 'collapsing bounds'};
model(end).ticklabels = {'starting point bias', 'input bias', '\lambda bias'};
model(end).colors = [cols2([5 3 4], :)];
model(end).basevalue = unique(results.ddmD_vanilla_aic);
model(end).ylim = [-8000 -6000];
model(end).subplot = 5;
% move subplots closer together
subplot = @(m,n,p) subtightplot (m, n, p, [0.01 0.03], [0.1 0.01], [0.1 0.01]);
close all;
set(gcf, 'defaultaxesfontsize', 4, 'defaultaxestitlefontsizemultiplier', 1);
for m = 1:length(model),
%everything relative to the full model
mdldic = bsxfun(@minus, mean(model(m).data), mean(model(m).basevalue));
subplot(2,max([model(:).subplot]), model(m).subplot);
hold on;
vn = unique(model(m).vanilla) - model(m).basevalue;
plot([0.5 3.5], [vn vn], 'k-');
%%%%%%
for i = 1:length(mdldic),
b = bar(i, mdldic(i), 'facecolor', model(m).colors(i, :), 'barwidth', 0.7, 'BaseValue', 0, ...
'edgecolor', 'none');
end
% outline the best fit
[~, i] = min(mdldic);
bar(i, mdldic(i), 'facecolor', model(m).colors(i, :), 'barwidth', 0.7, 'BaseValue', 0, ...
'edgecolor', 'k');
% now break the y-axes
xlim([0.5 length(mdldic)+0.5]);
hline(0, [0 0 0]);
ylim(model(m).ylim);
disp(get(gca, 'ylim'))
if m > 0
for i = 1:length(mdldic)
text(i, min([0 mdldic(i)]) + 0.05*range(get(gca, 'ylim')), ...
num2str(round(mdldic(i))), ...
'VerticalAlignment', 'bottom', 'FontSize', 4, ...
'horizontalalignment', 'center', 'color', 'w');
end
else
for i = 1:length(mdldic)
text(i, min([0 mdldic(i)]) - 0.1*range(get(gca, 'ylim')), ...
num2str(round(mdldic(i))), ...
'VerticalAlignment', 'bottom', 'FontSize', 4, ...
'horizontalalignment', 'center', 'color', 'w');
end
end
box off;
set(gca, 'color', 'none');
set(gca, 'xcolor', 'k', 'ycolor', 'k');
offsetAxes;
set(gca, 'xtick', 1:length(model(m).ticklabels), ...
'xticklabel', model(m).ticklabels, 'xticklabelrotation', -30);
title(model(m).name, 'fontweight', 'normal', 'fontangle', 'italic');
axis square;
switch m
case 1
ylabel({'\DeltaAIC from DDM'; 'without history'}, 'interpreter', 'tex');
case 3
ylabel({'\DeltaAIC from dyn-DDM'; 'without history'}, 'interpreter', 'tex');
otherwise
set(gca, 'ycolor', 'w', 'yticklabel', []);
end
end
%xlabel('DDM');
drawnow; tightfig;
print(gcf, '-dpdf', sprintf('~/Data/serialHDDM/AIC_kostis_all.pdf'));
end