


Function to do multiple comparisons tests based on Family Wise
Error rates using one of a set of multiple comparisons procedures
Usage: H=multiple_comparisons(p,q,method)
or [H,K]=multiple_comparisons(p,q,method)
Inputs:
p : a collection of p values - required
q : threshold for multiple comparisons (i.e. a p value for the tests)
method: 'bonxxxx' - Bonferroni correction
'holxxxx' - Holm step-up procedure
'hocxxxx' - Hochberg step-down procedure
'fdrxxxx' - false discovery rate
Output:
H : collection of 1s and 0s
1s - do not reject the null hypothesis
0s - reject the null hypothesis
(dimension of H is the same as the dimension of p)
K : the FDR based method can be used when assuming independence or
positive dependece of the tests as well as when no such assumption is
invoked. K contains the results without any dependency assumption and H
contains the results with an independent or positive dependence
assumption. K is also a collection of 1s and 0s (as with H). When the
other methods are used K is simply a collection of 1s.

0001 function [H,K]=multiple_comparison(p,q,method) 0002 % Function to do multiple comparisons tests based on Family Wise 0003 % Error rates using one of a set of multiple comparisons procedures 0004 % 0005 % Usage: H=multiple_comparisons(p,q,method) 0006 % or [H,K]=multiple_comparisons(p,q,method) 0007 % Inputs: 0008 % p : a collection of p values - required 0009 % q : threshold for multiple comparisons (i.e. a p value for the tests) 0010 % method: 'bonxxxx' - Bonferroni correction 0011 % 'holxxxx' - Holm step-up procedure 0012 % 'hocxxxx' - Hochberg step-down procedure 0013 % 'fdrxxxx' - false discovery rate 0014 % Output: 0015 % H : collection of 1s and 0s 0016 % 1s - do not reject the null hypothesis 0017 % 0s - reject the null hypothesis 0018 % (dimension of H is the same as the dimension of p) 0019 % K : the FDR based method can be used when assuming independence or 0020 % positive dependece of the tests as well as when no such assumption is 0021 % invoked. K contains the results without any dependency assumption and H 0022 % contains the results with an independent or positive dependence 0023 % assumption. K is also a collection of 1s and 0s (as with H). When the 0024 % other methods are used K is simply a collection of 1s. 0025 0026 k=length(p); 0027 H=ones(1,k); 0028 K=ones(1,k); 0029 method=method(1:3); 0030 if strcmp(method,'bon') 0031 q=q/k; 0032 indx=find(p<q); 0033 H(indx)=0; 0034 elseif strcmp(method,'hol'); 0035 [psort,indxsort]=sort(p); 0036 q=q./(k-[1:k]+1); 0037 n=0; 0038 doloop=1; 0039 while doloop==1 && n < k; 0040 n=n+1; 0041 if psort(n) > q(n) 0042 doloop=0; 0043 end; 0044 end; 0045 H(indxsort(1:n-1))=0; 0046 elseif strcmp(method,'hoc'); 0047 [psort,indxsort]=sort(p); 0048 q=q./(k-[1:k]+1); 0049 n=k+1; 0050 doloop=1; 0051 while doloop==1 && n > 1 0052 n=n-1; 0053 if psort(n) <= q(n) 0054 doloop=0; 0055 end; 0056 end; 0057 if doloop==0; H(indxsort(1:n))=0;end 0058 elseif strcmp(method,'fdr'); 0059 [psort,indxsort]=sort(p); 0060 q=[1:k].*q/k; 0061 n=k+1; 0062 doloop=1; 0063 while doloop==1 && n>1; 0064 n=n-1; 0065 if psort(n)<=q(n); 0066 doloop=0; 0067 end; 0068 end; 0069 if doloop==0; H(indxsort(1:n))=0; end; 0070 % [pID,pN] = FDR(p,q); 0071 % if ~isempty(pID); 0072 % indx1=find(p<pID); 0073 % H(indx1)=0; 0074 % end; 0075 % if ~isempty(pN); 0076 % indx2=find(p<pN); 0077 % K(indx2)=0; 0078 % end; 0079 end; 0080 0081 0082 0083