-
Notifications
You must be signed in to change notification settings - Fork 1
/
mcn-test.R
31 lines (25 loc) · 926 Bytes
/
mcn-test.R
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
mcn.test = function(v1, v2)
{
M11 = sum(v1 == "TP" & v2 == "TP") +
sum(v1 == "TN" & v2 == "TN")
M01 = sum(v1 == "FP" & v2 == "TP") +
sum(v1 == "FP" & v2 == "TN") +
sum(v1 == "FN" & v2 == "TP") +
sum(v1 == "FN" & v2 == "TN") +
sum(v1 == "N0" & v2 == "TP") +
sum(v1 == "N0" & v2 == "TN") +
sum(v1 == "N1" & v2 == "TP") +
sum(v1 == "N1" & v2 == "TN")
M10 = sum(v1 == "TP" & v2 == "FP") +
sum(v1 == "TP" & v2 == "FN") +
sum(v1 == "TP" & v2 == "N0") +
sum(v1 == "TP" & v2 == "N1") +
sum(v1 == "TN" & v2 == "FP") +
sum(v1 == "TN" & v2 == "FN") +
sum(v1 == "TN" & v2 == "N0") +
sum(v1 == "TN" & v2 == "N1")
M00 = nrow(v1) - M11 - M01 - M10
performance = matrix(c(M00, M10, M01, M11), nrow=2)
pval = mcnemar.test(performance)$p.value
return (pval)
}