-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfit_empa.m
111 lines (80 loc) · 2.9 KB
/
fit_empa.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
%clear all;
%load('mat/fmri_empaLik_reg_1_vgfmri3_helper_old.mat');
%load('mat/fmri_empaLik_best_1_vgfmri3_helper_old.mat');
%load('mat/fmri_empaLik_orig_1_vgfmri3_helper_old.mat');
%load('mat/fmri_empaLik_orig_1_vgfmri3_chase.mat');
%load('mat/fmri_empaLik_orig_1_vgfmri3_bait.mat');
%load('mat/fmri_empaLik_orig_1_vgfmri3_helper.mat');
%load('mat/fmri_empaLik_orig_1_vgfmri3_zelda.mat');
%load('mat/fmri_empaLik_orig_1_vgfmri3_lemmings.mat');
%load('mat/fmri_empaLik_orig_1_vgfmri3_plaqueAttack.mat');
%helper(behavior, predictions);
%load('mat/fmri_empaLik_best_1_vgfmri3_chase.mat');
%load('mat/fmri_empaLik_best_1_vgfmri3_bait.mat');
%load('mat/fmri_empaLik_best_1_vgfmri3_helper.mat');
%load('mat/fmri_empaLik_best_1_vgfmri3_zelda.mat');
%load('mat/fmri_empaLik_best_1_vgfmri3_lemmings.mat');
%load('mat/fmri_empaLik_best_1_vgfmri3_plaqueAttack.mat');
%helper(behavior, predictions);
game_names = { ...
'vgfmri3_chase'; ...
'vgfmri3_helper'; ...
'vgfmri3_bait'; ...
'vgfmri3_zelda'; ...
'vgfmri3_lemmings'; ...
'vgfmri3_plaqueAttack'};
original_logliks = [];
decoded_logliks = [];
p_values = [];
LR_stats = [];
original_BICs = [];
decoded_BICs = [];
BIC_diffs = [];
for g = 1:length(game_names)
[lo, lb] = compare(game_names{g});
original_logliks = [original_logliks; lo];
decoded_logliks = [decoded_logliks; lb];
[h,p,stat,c] = lratiotest(lb, lo, 1);
p_values = [p_values; p];
LR_stats = [LR_stats; stat];
original_BICs = [original_BICs; - 2 * lo];
decoded_BICs = [decoded_BICs; - 2 * lb];
BIC_diffs = [BIC_diffs; -2*lo - (-2*lb)];
end
T = table(game_names, original_logliks, decoded_logliks, p_values, LR_stats, original_BICs, decoded_BICs, BIC_diffs)
% log lik original, log lik best (decoded)
function [lo, lb] = compare(game_name)
load(sprintf('mat/fmri_empaLik_orig_1_%s.mat', game_name));
pko = play_keys;
if ischar(pko)
pko = cellstr(pko);
end
load(sprintf('mat/fmri_empaLik_best_1_%s.mat', game_name));
pkb = play_keys;
if ischar(pkb)
pkb = cellstr(pkb);
end
l = min(length(pko), length(pkb));
pko = pko(1:l);
pkb = pkb(1:l);
which = strcmp(pko, pkb);
load(sprintf('mat/fmri_empaLik_orig_1_%s.mat', game_name));
[orig, lo] = helper(behavior, predictions, which);
load(sprintf('mat/fmri_empaLik_best_1_%s.mat', game_name));
[best, lb] = helper(behavior, predictions, which);
end
function [data, loglik] = helper(behavior, predictions, which)
x = [0.1];
if ischar(behavior)
data(1).behavior = cellstr(squeeze(behavior));
else
data(1).behavior = behavior;
end
data(1).predictions = predictions;
if ~exist('which', 'var')
which = logical(ones(1, length(data(1).behavior)));
end
data(1).behavior = data(1).behavior(which);
data(1).predictions = data(1).predictions(which);
loglik = lik_empa(x, data(1));
end