yat
0.14.5pre
|
#include <yat/statistics/Fisher.h>
Public Member Functions | |
Fisher (bool yates=false) | |
virtual | ~Fisher (void) |
double | Chi2 (void) const |
void | expected (double &a, double &b, double &c, double &d) const |
unsigned int & | minimum_size (void) |
const unsigned int & | minimum_size (void) const |
double | p_left (void) const |
double | p_right (void) const |
double | p_value (void) const |
double | p_value_one_sided () const |
double | oddsratio (const unsigned int a, const unsigned int b, const unsigned int c, const unsigned int d) |
double | oddsratio (void) const |
Fisher's exact test.
Fisher's Exact test is a procedure that you can use for data in a two by two contingency table:
Fisher's Exact Test is based on exact probabilities from a specific distribution (the hypergeometric distribution). There's really no lower bound on the amount of data that is needed for Fisher's Exact Test. You do have to have at least one data value in each row and one data value in each column. If an entire row or column is zero, then you don't really have a 2 by 2 table. But you can use Fisher's Exact Test when one of the cells in your table has a zero in it. Fisher's Exact Test is also very useful for highly imbalanced tables. If one or two of the cells in a two by two table have numbers in the thousands and one or two of the other cells has numbers less than 5, you can still use Fisher's Exact Test. For very large tables (where all four entries in the two by two table are large), your computer may take too much time to compute Fisher's Exact Test. In these situations, though, you might as well use the Chi-square test because a large sample approximation (that the Chi-square test relies on) is very reasonable. If all elements are larger than 10 a Chi-square test is reasonable to use.
theplu::yat::statistics::Fisher::Fisher | ( | bool | yates = false | ) |
Default Constructor.
yates | if true Yates's correction is used for chi-squared calculation |
|
virtual |
Destructor
double theplu::yat::statistics::Fisher::Chi2 | ( | void | ) | const |
The Chi2 score is calculated as where E is expected value and O is observed value.
If indicated in constructor, Yates's correction is used, i.e., Chi2 is calculated as
void theplu::yat::statistics::Fisher::expected | ( | double & | a, |
double & | b, | ||
double & | c, | ||
double & | d | ||
) | const |
Calculates the expected values under the null hypothesis. , , , ,
unsigned int& theplu::yat::statistics::Fisher::minimum_size | ( | void | ) |
If all elements in table is at least minimum_size(), a Chi2 approximation is used for p-value calculation.
const unsigned int& theplu::yat::statistics::Fisher::minimum_size | ( | void | ) | const |
If all elements in table is at least minimum_size(), a Chi2 approximation is used for p-value calculation.
double theplu::yat::statistics::Fisher::oddsratio | ( | const unsigned int | a, |
const unsigned int | b, | ||
const unsigned int | c, | ||
const unsigned int | d | ||
) |
Function calculating odds ratio from 2x2 table
as
Object will remember the values of a, b, c, and d.
If | table is invalid a runtime_error is thrown. A table is invalid if a row or column sum is zero. |
double theplu::yat::statistics::Fisher::oddsratio | ( | void | ) | const |
double theplu::yat::statistics::Fisher::p_left | ( | void | ) | const |
Calculates probability to get oddsratio (or smaller).
If all elements in table is at least minimum_size(), a Chi2 approximation is used.
double theplu::yat::statistics::Fisher::p_right | ( | void | ) | const |
Calculates probability to get oddsratio (or greater).
If all elements in table is at least minimum_size(), a Chi2 approximation is used.
double theplu::yat::statistics::Fisher::p_value | ( | void | ) | const |
If all elements in table is at least minimum_size(), a Chi2 approximation is used.
Otherwise a two-sided p-value is calculated using the hypergeometric distribution where summation runs over k such that .
double theplu::yat::statistics::Fisher::p_value_one_sided | ( | ) | const |
One-sided p-value is probability to get larger (or equal) oddsratio.
If all elements in table is at least minimum_size(), a Chi2 approximation is used.