Ignore:
Timestamp:
Mar 4, 2007, 1:34:17 PM (15 years ago)
Author:
Peter
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
Added
Removed
  • trunk/yat/statistics/Fisher.h

    r760 r777  
    6969  */
    7070 
    71   class Fisher : public Score
     71  class Fisher
    7272  {
    7373 
     
    7676    /// Default Constructor.
    7777    ///
    78     Fisher(bool absolute=true);
     78    Fisher(void);
    7979
    8080    ///
    8181    /// Destructor
    8282    ///
    83     virtual ~Fisher(void) {};
     83    virtual ~Fisher(void);
    8484         
    8585   
     
    8989    double Chi2(void) const;
    9090
    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    */
    9598    void expected(double& a, double& b, double& c, double& d) const;
    9699
    97100    ///
    98     /// minimum_size is the threshold for when the p-value calculation
    99     /// is performed using a Chi2 approximation.
     101    /// If all elements in table is at least minimum_size(), a Chi2
     102    /// approximation is used for p-value calculation.
    100103    ///
    101104    /// @return reference to minimum_size
     
    104107
    105108    ///
    106     /// If absolute, the p-value is the two-sided p-value. 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 p-value 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, two-sided p-value is equal
     118    /// to 2*p_value_one_sided(). If oddsratio is smaller than unity
     119    /// two-sided p-value is equal to 2*(1-p_value_one_sided()). If
     120    /// oddsratio is unity two-sided p-value is equal to unity.
     121    ///
     122    /// If all elements in table is at least minimum_size(), a Chi2
    108123    /// approximation is used.
    109124    ///
    110     /// @return p-value
    111     ///
    112     /// @note in weighted case, approximation Chi2 is always used.
     125    /// @return 2-sided p-value
    113126    ///
    114127    double p_value() const;
    115128   
    116129    ///
    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    /// One-sided p-value is probability to get larger (or equal) oddsratio.
    122131    ///
    123     /// @return odds ratio. If absolute_ is true and odds ratio is
    124     /// less than unity 1 divided by odds ratio is returned
     132    /// If all elements in table is at least minimum_size(), a Chi2
     133    /// approximation is used.
    125134    ///
    126     /// @throw If table is invalid a runtime_error is thrown.
     135    /// @return One-sided p-value
    127136    ///
    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}{|c|c|}
     142       \hline a&b \tabularnewline \hline c&d \tabularnewline \hline
     143       \end{tabular} \f] as \f$ \frac{ad}{bc} \f$
    130144
    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.
    144146
    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);
    179152
    180153  private:
    181     double oddsratio(const double a, const double b,
    182                      const double c, const double d);
     154    bool calculate_p_exact() const;
    183155
    184156    // two-sided
     
    187159    double p_value_exact(void) const;
    188160
    189     double a_;
    190     double b_;
    191     double c_;
    192     double d_;
     161    u_int a_;
     162    u_int b_;
     163    u_int c_;
     164    u_int d_;
    193165    u_int minimum_size_;
    194166    double oddsratio_;
    195     double value_cutoff_;
    196167  };
    197168
Note: See TracChangeset for help on using the changeset viewer.