Home > GVSToolbox > sortVariablesANOVA.m

sortVariablesANOVA

PURPOSE ^

anova ranking of variables

SYNOPSIS ^

function [bestVariables bestToWorst p ] = sortVariablesANOVA( featureVect,classLabels, topVarsToKeep )

DESCRIPTION ^

 anova ranking of variables
 
 syntax: [bestVariables bestToWorst p ] = sortVariablesANOVA( featureVect, ...
                         classLabels, topVarsToKeep )
 
 Inputs:
   featureVect: all the the data samples in (dim x numSamples)
   classLabels: all class labels (0 for not learned, 1 for learned, 2 unsure.  
      The ones labeled class 2 will not be used.
   topVarsToKeep: index of number of best variables to return
 
 Outputs:
   bestVariables: indices of best variables to separate the classes
   bestToWorst: index ordering all the variables for all CV folds
   p: associated p values for those indices

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 % anova ranking of variables
0002 %
0003 % syntax: [bestVariables bestToWorst p ] = sortVariablesANOVA( featureVect, ...
0004 %                         classLabels, topVarsToKeep )
0005 %
0006 % Inputs:
0007 %   featureVect: all the the data samples in (dim x numSamples)
0008 %   classLabels: all class labels (0 for not learned, 1 for learned, 2 unsure.
0009 %      The ones labeled class 2 will not be used.
0010 %   topVarsToKeep: index of number of best variables to return
0011 %
0012 % Outputs:
0013 %   bestVariables: indices of best variables to separate the classes
0014 %   bestToWorst: index ordering all the variables for all CV folds
0015 %   p: associated p values for those indices
0016 %
0017 
0018 
0019 function [bestVariables bestToWorst p ] = sortVariablesANOVA( featureVect, ...
0020                         classLabels, topVarsToKeep )
0021                   
0022 
0023 if nargin < 4 || isempty( topVarsToKeep)
0024     topVarsToKeep = 10;
0025 end
0026 % if nargin < 5 || isempty( topVarsToSearch )
0027 %     topVarsToSearch = topVarsToKeep;
0028 % end
0029 
0030 % leave one subject out cross validation
0031 [ dim numSamples] = size( featureVect);
0032 % expLabels = getLeave1OutLabels( numSamples, numSamplesPerSubj);
0033 % numTrials = length(expLabels);
0034 p = zeros( dim,1);
0035 h = zeros(dim,1);
0036 
0037 featureVect(:,classLabels ==2) = [];
0038 classLabels( classLabels ==2) = []; 
0039 
0040 % do the tests on each feature
0041 for i2 = 1:dim
0042     [h(i2,1) p(i2,1) ] = ttest2( featureVect( i2, classLabels==0)', ...
0043                      featureVect( i2, classLabels==1)',...
0044                       .05, 'both', 'unequal');        
0045 end    
0046 % [h p]  = ttest2(x,y, .05, 'both', 'unequal') %2 tailed, unequal
0047 % variances, 5% significance evel
0048 % h = 1 means reject, so different means
0049 % p  very small is probability you see that data, given null hypothesis.
0050 % So a low value is good (different means)
0051 
0052 % sort variables in order best to worst
0053 [ p bestToWorst] = sort( p, 1, 'ascend');
0054 
0055 % remove redundancies
0056 unqIdx = findRedundancies( featureVect( bestToWorst,:) );
0057 bestToWorst = bestToWorst(unqIdx);
0058 
0059 bestVariables = bestToWorst(1:topVarsToKeep);
0060 
0061

Generated on Tue 01-Jul-2014 12:35:04 by m2html © 2005