Changeset 777 for trunk/yat/statistics/Fisher.h
 Timestamp:
 Mar 4, 2007, 1:34:17 PM (15 years ago)
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

trunk/yat/statistics/Fisher.h
r760 r777 69 69 */ 70 70 71 class Fisher : public Score71 class Fisher 72 72 { 73 73 … … 76 76 /// Default Constructor. 77 77 /// 78 Fisher( bool absolute=true);78 Fisher(void); 79 79 80 80 /// 81 81 /// Destructor 82 82 /// 83 virtual ~Fisher(void) {};83 virtual ~Fisher(void); 84 84 85 85 … … 89 89 double Chi2(void) const; 90 90 91 /// 92 /// Calculates the expected values under the null hypothesis. 93 /// a' = (a+c)(a+b)/(a+b+c+d) 94 /// 91 /** 92 Calculates the expected values under the null hypothesis. 93 \f$ a' = \frac{(a+c)(a+b)}{a+b+c+d} \f$, 94 \f$ b' = \frac{(a+b)(b+d)}{a+b+c+d} \f$, 95 \f$ c' = \frac{(a+c)(c+d)}{a+b+c+d} \f$, 96 \f$ d' = \frac{(b+d)(c+d)}{a+b+c+d} \f$, 97 */ 95 98 void expected(double& a, double& b, double& c, double& d) const; 96 99 97 100 /// 98 /// minimum_size is the threshold for when the pvalue calculation99 /// is performed using a Chi2 approximation.101 /// If all elements in table is at least minimum_size(), a Chi2 102 /// approximation is used for pvalue calculation. 100 103 /// 101 104 /// @return reference to minimum_size … … 104 107 105 108 /// 106 /// If absolute, the pvalue is the twosided pvalue. If all 107 /// elements in table is at least minimum_size, a Chi2 109 /// If all elements in table is at least minimum_size(), a Chi2 110 /// approximation is used for pvalue calculation. 111 /// 112 /// @return const reference to minimum_size 113 /// 114 const u_int& minimum_size(void) const; 115 116 /// 117 /// If oddsratio is larger than unity, twosided pvalue is equal 118 /// to 2*p_value_one_sided(). If oddsratio is smaller than unity 119 /// twosided pvalue is equal to 2*(1p_value_one_sided()). If 120 /// oddsratio is unity twosided pvalue is equal to unity. 121 /// 122 /// If all elements in table is at least minimum_size(), a Chi2 108 123 /// approximation is used. 109 124 /// 110 /// @return pvalue 111 /// 112 /// @note in weighted case, approximation Chi2 is always used. 125 /// @return 2sided pvalue 113 126 /// 114 127 double p_value() const; 115 128 116 129 /// 117 /// Function calculating score from 2x2 table for which the 118 /// elements are calculated as follows \n 119 /// target.binary(i) sample i in group a or c otherwise in b or d 120 /// \f$ value(i) > \f$ value_cutoff() sample i in group a or b 121 /// otherwise c or d\n 130 /// Onesided pvalue is probability to get larger (or equal) oddsratio. 122 131 /// 123 /// @return odds ratio. If absolute_ is true and odds ratio is124 /// less than unity 1 divided by odds ratio is returned132 /// If all elements in table is at least minimum_size(), a Chi2 133 /// approximation is used. 125 134 /// 126 /// @ throw If table is invalid a runtime_error is thrown.135 /// @return Onesided pvalue 127 136 /// 128 double score(const classifier::Target& target, 129 const utility::vector& value); 137 double p_value_one_sided() const; 138 139 /** 140 Function calculating odds ratio from 2x2 table 141 \f[ \begin{tabular}{cc} 142 \hline a&b \tabularnewline \hline c&d \tabularnewline \hline 143 \end{tabular} \f] as \f$ \frac{ad}{bc} \f$ 130 144 131 /// 132 /// Weighted version of score. Each element in 2x2 table is 133 /// calculated as \f$ \sum w_i \f$, so when each weight is 134 /// unitary the same table is created as in the unweighted version 135 /// 136 /// @return odds ratio 137 /// 138 /// @see score 139 /// 140 /// @throw If table is invalid a runtime_error is thrown. 141 /// 142 double score(const classifier::Target& target, 143 const classifier::DataLookupWeighted1D& value); 145 @return odds ratio. 144 146 145 146 /// 147 /// Weighted version of score. Each element in 2x2 table is 148 /// calculated as \f$ \sum w_i \f$, so when each weight is 149 /// unitary the same table is created as in the unweighted version 150 /// 151 /// @return odds ratio 152 /// 153 /// @see score 154 /// 155 /// @throw If table is invalid a runtime_error is thrown. 156 /// 157 double score(const classifier::Target& target, 158 const utility::vector& value, 159 const utility::vector& weight); 160 161 /// 162 /// \f$ \frac{ad}{bc} \f$ 163 /// 164 /// @return odds ratio. If absolute_ is true and odds ratio is 165 /// less than unity, 1 divided by odds ratio is returned 166 /// 167 /// @throw If table is invalid a runtime_error is thrown. 168 /// 169 double score(const u_int a, const u_int b, 170 const u_int c, const u_int d); 171 172 /// 173 /// Cutoff sets the limit whether a value should go into the left 174 /// or the right row. @see score 175 /// 176 /// @return reference to cutoff for row 177 /// 178 double& value_cutoff(void); 147 @throw If table is invalid a runtime_error is thrown. A table 148 is invalid if a row or column sum is zero. 149 */ 150 double oddsratio(const u_int a, const u_int b, 151 const u_int c, const u_int d); 179 152 180 153 private: 181 double oddsratio(const double a, const double b, 182 const double c, const double d); 154 bool calculate_p_exact() const; 183 155 184 156 // twosided … … 187 159 double p_value_exact(void) const; 188 160 189 doublea_;190 doubleb_;191 doublec_;192 doubled_;161 u_int a_; 162 u_int b_; 163 u_int c_; 164 u_int d_; 193 165 u_int minimum_size_; 194 166 double oddsratio_; 195 double value_cutoff_;196 167 }; 197 168
Note: See TracChangeset
for help on using the changeset viewer.