-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcNemEce.m
72 lines (48 loc) · 1.64 KB
/
mcNemEce.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
function [midPvalue] = mcNemEce(vector,alpha)
% this function computes one tailed mid-p McNemar test
% source : The McNemar test for binary matched-pairs data (Fagerland et
% al., 2013) - additional material (How to calculate the McNemar mid-p
% test)
%Group 1
% --------------
% A I
% --------------
% A a b
% Group 2
% I c d
% --------------
%
% A = accurate
% I = inaccurate
% group 1 = group 2
% table must be 2X2, joint outcome probabilities
% a = correct in both groups
% b = correct in the second but wrong in the first
% c = correct in the first, wrong in the second
% d = incorrect in both
% vector = [a,b,c,d];
% start with exact conditional test
% get the discordant pairs (mcNem test does not care about concordant
% pairs)
b = vector(2);
c = vector(3);
discordantTotal = b+c;
p = 0.5; % one sided exact conditional p value is probability of at least b succeses out of
% n (discordant total) binomial trials
if b < c % this test assumes b being equal or lower than c
exactPvalue = 2*binocdf(b,discordantTotal,p);
% this assumes b < c, if b = c , p returns 1
elseif b == c
exactPvalue = 1;
elseif b > c
disp(' ERROR : change the order of the comparison groups');
end
midPvalue = exactPvalue-0.5*binopdf(b,discordantTotal,p);
% significance check
if midPvalue < alpha
disp('groups are significantly different - McNem');
disp(midPvalue);
elseif midPvalue > alpha
disp('groups are not significantly different, _McNem');
disp(midPvalue);
end