-
Notifications
You must be signed in to change notification settings - Fork 4
/
barplots_modelcomparison_regression.m
104 lines (85 loc) · 2.88 KB
/
barplots_modelcomparison_regression.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
function barplots_modelcomparison_regression()
% 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
addpath(genpath('~/code/Tools'));
warning off; close all;
global datasets datasetnames mypath colors
modelIC = {'aic'};
for s = 1:length(modelIC),
% ============================================ %
% DIC COMPARISON BETWEEN DC, Z AND BOTH
% ============================================ %
% 1. STIMCODING, only prevresps
mdls = {'regress_nohist', ...
'regress_z_lag1', ...
'regress_dc_lag1', ...
'regress_dcz_lag1', ...
'regress_z_lag2', ...
'regress_dc_lag2', ...
'regress_dcz_lag2', ...
'regress_z_lag3', ...
'regress_dc_lag3', ...
'regress_dcz_lag3', ...
'regress_z_lag4', ...
'regress_dc_lag4', ...
'regress_dcz_lag4', ...
'regress_z_lag5', ...
'regress_dc_lag5', ...
'regress_dcz_lag5', ...
'regress_z_lag6', ...
'regress_dc_lag6', ...
'regress_dcz_lag6'};
numlags = 6;
lagnames = {'1', '2', '3', '4', '5', '6'};
for d = 1:length(datasets),
close all;
subplot(4, 4, 1);
getPlotModelIC(mdls, modelIC{s}, d, colors);
title(datasetnames{d});
set(gca, 'xtick', 1:numlags, 'xticklabel', lagnames);
xlabel('Lags (# trials)')
ylabel({'\DeltaAIC from model'; 'without history'}, 'interpreter', 'tex');
drawnow; tightfig;
print(gcf, '-dpdf', sprintf('~/Data/serialHDDM/modelcomparison_regression_%s_d%d.pdf', modelIC{s}, d));
disp(d);
end
end
close all;
end
% ============================================ %
% DIC COMPARISON BETWEEN DC, Z AND BOTH
% ============================================ %
function getPlotModelIC(mdls, s, d, colors)
global datasets mypath
axis square; hold on;
plot([1 6], [0 0], 'color', 'k', 'linewidth', 0.5);
mdldic = nan(1, length(mdls));
for m = 1:length(mdls),
try
modelcomp = readtable(sprintf('%s/%s/%s/model_comparison.csv', ...
mypath, datasets{d}, mdls{m}), 'readrownames', true);
mdldic(m) = modelcomp.(s);
catch
fprintf('%s/%s/%s/model_comparison.csv NOT FOUND\n', ...
mypath, datasets{d}, mdls{m})
end
end
% everything relative to the full model
mdldic = bsxfun(@minus, mdldic, mdldic(1));
mdldic = mdldic(2:end);
mdls = mdls(2:end);
[~, bestMdl] = min(mdldic);
for c = 1:3,
b = plot(1:6, mdldic(c:3:end), 'o-', 'color', colors(c, :),'markersize', 5, ...
'markerfacecolor', colors(c, :), 'markeredgecolor', [1 1 1]);
end
axis square; axis tight;
set(gca, 'xtick', 1:6);
offsetAxes; box off;
% set(gca, 'color', 'none');
set(gca, 'xcolor', 'k', 'ycolor', 'k');
end