# Changeset 777 for trunk/yat/statistics/Fisher.h

Ignore:
Timestamp:
Mar 4, 2007, 1:34:17 PM (16 years ago)
Message:

Changed Fisher interface dramatically. No longer inherited from Score. Removed several functions since they encourage inappropriate usage. Removed support for weights. refs #101

File:
1 edited

### Legend:

Unmodified
 r760 */ class Fisher : public Score class Fisher { /// Default Constructor. /// Fisher(bool absolute=true); Fisher(void); /// /// Destructor /// virtual ~Fisher(void) {}; virtual ~Fisher(void); double Chi2(void) const; /// /// Calculates the expected values under the null hypothesis. /// a' = (a+c)(a+b)/(a+b+c+d) /// /** Calculates the expected values under the null hypothesis. \f$a' = \frac{(a+c)(a+b)}{a+b+c+d} \f$, \f$b' = \frac{(a+b)(b+d)}{a+b+c+d} \f$, \f$c' = \frac{(a+c)(c+d)}{a+b+c+d} \f$, \f$d' = \frac{(b+d)(c+d)}{a+b+c+d} \f$, */ void expected(double& a, double& b, double& c, double& d) const; /// /// minimum_size is the threshold for when the p-value calculation /// is performed using a Chi2 approximation. /// If all elements in table is at least minimum_size(), a Chi2 /// approximation is used for p-value calculation. /// /// @return reference to minimum_size /// /// If absolute, the p-value is the two-sided p-value. If all /// elements in table is at least minimum_size, a Chi2 /// If all elements in table is at least minimum_size(), a Chi2 /// approximation is used for p-value calculation. /// /// @return const reference to minimum_size /// const u_int& minimum_size(void) const; /// /// If oddsratio is larger than unity, two-sided p-value is equal /// to 2*p_value_one_sided(). If oddsratio is smaller than unity /// two-sided p-value is equal to 2*(1-p_value_one_sided()). If /// oddsratio is unity two-sided p-value is equal to unity. /// /// If all elements in table is at least minimum_size(), a Chi2 /// approximation is used. /// /// @return p-value /// /// @note in weighted case, approximation Chi2 is always used. /// @return 2-sided p-value /// double p_value() const; /// /// Function calculating score from 2x2 table for which the /// elements are calculated as follows \n /// target.binary(i) sample i in group a or c otherwise in b or d /// \f$value(i) > \f$ value_cutoff() sample i in group a or b /// otherwise c or d\n /// One-sided p-value is probability to get larger (or equal) oddsratio. /// /// @return odds ratio. If absolute_ is true and odds ratio is /// less than unity 1 divided by odds ratio is returned /// If all elements in table is at least minimum_size(), a Chi2 /// approximation is used. /// /// @throw If table is invalid a runtime_error is thrown. /// @return One-sided p-value /// double score(const classifier::Target& target, const utility::vector& value); double p_value_one_sided() const; /** Function calculating odds ratio from 2x2 table \f[ \begin{tabular}{|c|c|} \hline a&b \tabularnewline \hline c&d \tabularnewline \hline \end{tabular} \f] as \f$\frac{ad}{bc} \f$ /// /// Weighted version of score. Each element in 2x2 table is /// calculated as \f$\sum w_i \f$, so when each weight is /// unitary the same table is created as in the unweighted version /// /// @return odds ratio /// /// @see score /// /// @throw If table is invalid a runtime_error is thrown. /// double score(const classifier::Target& target, const classifier::DataLookupWeighted1D& value); @return odds ratio. /// /// Weighted version of score. Each element in 2x2 table is /// calculated as \f$\sum w_i \f$, so when each weight is /// unitary the same table is created as in the unweighted version /// /// @return odds ratio /// /// @see score /// /// @throw If table is invalid a runtime_error is thrown. /// double score(const classifier::Target& target, const utility::vector& value, const utility::vector& weight); /// /// \f$\frac{ad}{bc} \f$ /// /// @return odds ratio. If absolute_ is true and odds ratio is /// less than unity, 1 divided by odds ratio is returned /// /// @throw If table is invalid a runtime_error is thrown. /// double score(const u_int a, const u_int b, const u_int c, const u_int d); /// /// Cutoff sets the limit whether a value should go into the left /// or the right row. @see score /// /// @return reference to cutoff for row /// double& value_cutoff(void); @throw If table is invalid a runtime_error is thrown. A table is invalid if a row or column sum is zero. */ double oddsratio(const u_int a, const u_int b, const u_int c, const u_int d); private: double oddsratio(const double a, const double b, const double c, const double d); bool calculate_p_exact() const; // two-sided double p_value_exact(void) const; double a_; double b_; double c_; double d_; u_int a_; u_int b_; u_int c_; u_int d_; u_int minimum_size_; double oddsratio_; double value_cutoff_; };