-
Notifications
You must be signed in to change notification settings - Fork 0
/
binomialFunction.m
32 lines (18 loc) · 994 Bytes
/
binomialFunction.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
function[BinomialTable] = binomialFunction(totalProbes,correctProbes,group)
% this function gets nr of probes and nr of correct probes and calculates
% accuracy, confidence intervals with binofit (for inferential stats) and binocdf (binomial distribution for P value), returns BinomialTable.
% totalProbes : total data set for given category - nr of times given
% probe is asked
% correctProbes : total correct responses for the given probe
% group : category you conduct the binomial test, should be string (e.g.
% 'face' or 'orientation'
alpha = 0.05;
chanceLevel = 0.5;
%accuracy
accuracy = correctProbes/totalProbes;
%binofit (confidence intervals)
[~,pci] = binofit(correctProbes,totalProbes , alpha);
%binocdf (returns p value for hypothesis testing)
PValue = 1-binocdf(correctProbes-1,totalProbes,chanceLevel);
BinomialTable = table([accuracy; pci(1); pci(2);PValue], 'VariableNames', {group}, 'RowNames', {'accuracy', 'LowerBound', 'UpperBound','PValue'});
end