-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfig_RT_analysis_2.m
54 lines (37 loc) · 1.72 KB
/
fig_RT_analysis_2.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
% using fitglme mixed effects
%load('RT_analysis_forglme.mat'); <-- from original draft
load('RT_analysis_forglme_v2_3.mat');
type = categorical(type); % 1 = action chunk, 2 = state chunk, 3 = bridge
experiment = categorical(experiment);
tbl = table(rt, type, subject, experiment);
which = rt > 0;
tbl = tbl(which,:);
tbl.rt = log(tbl.rt); % log transform
formula = 'rt ~ 1 + type + (1 + type | subject)';
result = fitglme(tbl, formula, 'Distribution', 'Normal', 'Link', 'Identity', 'FitMethod', 'Laplace');
[beta, names, stats] = fixedEffects(result);
H = [0 -1 1 ]; % bridge - state chunk
[p, F, DF1, DF2] = coefTest(result, H);
fprintf('fitglme bridge - state chunk contrast: = %f (expect positive), p = %f, F(%d,%d) = %f\n', H * beta, p, DF1, DF2, F);
H = [0 0 1 ]; % bridge - action chunk (note action chunk == intercept)
[p, F, DF1, DF2] = coefTest(result, H);
fprintf('fitglme bridge vs action chunk contrast: = %f (expect positive), p = %e, F(%d,%d) = %f\n', H * beta, p, DF1, DF2, F);
H = [0 1 0 ]; % state - action chunk (note action chunk == intercept)
[p, F, DF1, DF2] = coefTest(result, H);
fprintf('fitglme state vs action chunk contrast: = %f (expect positive), p = %e, F(%d,%d) = %f\n', H * beta, p, DF1, DF2, F);
figure;
b = rt(type == categorical(3) & rt > 0);
s = rt(type == categorical(2) & rt > 0);
histogram(log(s));
histogram(log(b));
legend({'state chunk', 'bridge'});
ylabel('# presses');
xlabel('log RT (log ms)');
%figure;
%m = [mean(action_chunk_RTs) mean(state_chunk_RTs) mean(bridge_RTs)];
%se = [sem(action_chunk_RTs) sem(state_chunk_RTs) sem(bridge_RTs)];
%bar(m);
%hold on;
%errorbar(m, se, 'linestyle', 'none', 'color', 'black');
%ylabel('RT (ms)');
%xticklabels({'action chunk', 'state chunk', 'boundary'});