# SOCR EduMaterials AnalysisActivities Fisher Exact

### From Socr

(→SOCR Analyses Example on Fisher's Exact Test) |
(→Example) |
||

(12 intermediate revisions not shown) | |||

Line 1: | Line 1: | ||

- | == | + | == [[SOCR_EduMaterials_AnalysesActivities | SOCR Analysis Activities]] - SOCR Analyses Example on Fisher's Exact Test Activity == |

+ | ===Applet=== | ||

+ | [http://www.socr.ucla.edu/htmls/ana/FishersExactTest_Analysis.html SOCR Fisher's exact Test Applet is available online here]. | ||

- | This | + | ===Background=== |

+ | You can find more details about the [http://en.wikipedia.org/wiki/Fisher%27s_exact_test Fisher's Exact Test here]. This demo is based on an example from Wolfram MathWorld [http://mathworld.wolfram.com/FishersExactTest.html Fisher's Exact Test]. | ||

- | + | ===Steps=== | |

'''1.''' Click on "'''Fisher's Exact Test'''" from the conbo box in the left panel. | '''1.''' Click on "'''Fisher's Exact Test'''" from the conbo box in the left panel. | ||

- | |||

- | |||

<center>[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig1.gif|700px]]</center> | <center>[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig1.gif|700px]]</center> | ||

- | |||

<center>[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig1A.gif|450px]]</center> | <center>[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig1A.gif|450px]]</center> | ||

- | + | '''2.''' Click on "'''Input'''" button. You'll see a screen like below waiting for your input | |

- | '''2.''' Click on "''' | + | |

<center>[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig2.gif|700px]]</center> | <center>[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig2.gif|700px]]</center> | ||

- | + | The minimum size of table is 2 by 2. We'll use 2 by 2 for our example. (Note that you can also change the number of rows and/or columns by clicking on the combo box.) | |

<center>[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig2A.gif|700px]]</center> | <center>[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig2A.gif|700px]]</center> | ||

- | + | Type in numbers into the cells. You can also change the text of the row and column names from "Row 1" etc., to something you like. | |

- | + | ||

- | + | <center>[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig2B.gif|700px]]</center> | |

- | <center>[[Image: | + | |

- | ''' | + | '''3.''' Click on the "'''Calculate'''" button and then "'''Result'''" to see the results. |

+ | <center>[[Image:SOCR_AnalysisActivities_ChiTable_Chu_061407_Fig3.gif|700px]]</center> | ||

- | + | '''Note''': if you happen to click on the "Clear" button in the middle of the procedure, all the data will be cleared out. Simply start over from step 1 and retrieve the data by clicking an '''EXAMPLE''' button. | |

+ | ===Notes=== | ||

+ | * The [http://www.socr.ucla.edu/htmls/ana/FishersExactTest_Analysis.html SOCR Fisher's Exact Test] provides calculations for examining the significance of the association (contingency) between the two kinds of classifications. These are in general represented by NxK matrices. | ||

+ | * Please note that in the following situations the [http://en.wikipedia.org/wiki/Fisher%27s_exact_test Exact Fisher's test] is very difficult to compute: | ||

+ | ** anytime the frequency counts (cell-values in the matrix) are large (say >9), and/or | ||

+ | ** the matrix-sizes > 2 (i.e., N and/or K >2). | ||

- | + | * P-value-cutoff is <math>p_o</math>, the starting likelihood of the matrix, which is used incrementally to compute the one-sided and the two-sided p-values of interest. Note that in general, the two-sided p-value will be quite different from 2 times the one-sided p-value! | |

+ | * In [http://socr.ucla.edu/htmls/SOCR_Analyses.html SOCR Analyses], to make this test work for all these situations, we use ''approximate'' p-values calculations according to the [http://www.siam.org/proceedings/datamining/2008/dm08_45_ojala.pdf MaskMetropolis MCMC method for random matrix generation]. | ||

- | + | * If your data is in any of these situations, we strongly recommend you also try the [http://www.socr.ucla.edu/htmls/ana/ChiSquareCT_Analysis.html SOCR Chi-Square Contingency Table Test], which is more stable, albeit also approximate. See the [[SOCR_EduMaterials_AnalysisActivities_Chi_Contingency | SOCR Chi-Square Contingency Table Activity]]. | |

+ | ===Example=== | ||

+ | * If the “Cochran conditions” are satisfied (no cell has count zero, and more than 80% of the cells have counts at least 5) the [http://www.r-project.org/ R calculations] are based on asymptotic chi-squared probabilities and matrix simulation is done conditional on the row and column marginals, and works only if the marginals are strictly positive (Patefield algorithm, 1981). | ||

+ | <code> > data <- matrix(c(13, 6, 29, 11, 16, 4), nr=3)</code><br> | ||

+ | <code> > data</code><br> | ||

+ | <code> [,1] [,2]</code><br> | ||

+ | <code> [1,] 13 11</code><br> | ||

+ | <code> [2,] 6 16</code><br> | ||

+ | <code> [3,] 29 4</code><br> | ||

+ | <code> > fisher.test(data, alternative = "greater")</code><br> | ||

+ | <code> Fisher's Exact Test for Count Data </code><br> | ||

+ | <code> data: data </code><br> | ||

+ | <code> p-value = 0.00001568</code><br> | ||

+ | <code> alternative hypothesis: greater </code> | ||

+ | * SOCR Calculations | ||

+ | <center>[[Image:SOCR_AnalysisActivities_FishersExactTest_Fig4.png|500px]]</center> | ||

- | |||

{{translate|pageName=http://wiki.stat.ucla.edu/socr/index.php?title=SOCR_EduMaterials_AnalysisActivities_FisherExact}} | {{translate|pageName=http://wiki.stat.ucla.edu/socr/index.php?title=SOCR_EduMaterials_AnalysisActivities_FisherExact}} |

## Current revision as of 19:34, 22 June 2010

## Contents |

## SOCR Analysis Activities - SOCR Analyses Example on Fisher's Exact Test Activity

### Applet

SOCR Fisher's exact Test Applet is available online here.

### Background

You can find more details about the Fisher's Exact Test here. This demo is based on an example from Wolfram MathWorld Fisher's Exact Test.

### Steps

**1.** Click on "**Fisher's Exact Test**" from the conbo box in the left panel.

**2.** Click on "**Input**" button. You'll see a screen like below waiting for your input

The minimum size of table is 2 by 2. We'll use 2 by 2 for our example. (Note that you can also change the number of rows and/or columns by clicking on the combo box.)

Type in numbers into the cells. You can also change the text of the row and column names from "Row 1" etc., to something you like.

**3.** Click on the "**Calculate**" button and then "**Result**" to see the results.

**Note**: if you happen to click on the "Clear" button in the middle of the procedure, all the data will be cleared out. Simply start over from step 1 and retrieve the data by clicking an **EXAMPLE** button.

### Notes

- The SOCR Fisher's Exact Test provides calculations for examining the significance of the association (contingency) between the two kinds of classifications. These are in general represented by NxK matrices.

- Please note that in the following situations the Exact Fisher's test is very difficult to compute:
- anytime the frequency counts (cell-values in the matrix) are large (say >9), and/or
- the matrix-sizes > 2 (i.e., N and/or K >2).

- P-value-cutoff is
*p*_{o}, the starting likelihood of the matrix, which is used incrementally to compute the one-sided and the two-sided p-values of interest. Note that in general, the two-sided p-value will be quite different from 2 times the one-sided p-value!

- In SOCR Analyses, to make this test work for all these situations, we use
*approximate*p-values calculations according to the MaskMetropolis MCMC method for random matrix generation.

- If your data is in any of these situations, we strongly recommend you also try the SOCR Chi-Square Contingency Table Test, which is more stable, albeit also approximate. See the SOCR Chi-Square Contingency Table Activity.

### Example

- If the “Cochran conditions” are satisfied (no cell has count zero, and more than 80% of the cells have counts at least 5) the R calculations are based on asymptotic chi-squared probabilities and matrix simulation is done conditional on the row and column marginals, and works only if the marginals are strictly positive (Patefield algorithm, 1981).

` > data <- matrix(c(13, 6, 29, 11, 16, 4), nr=3)`

` > data`

` [,1] [,2]`

` [1,] 13 11`

` [2,] 6 16`

` [3,] 29 4`

` > fisher.test(data, alternative = "greater")`

` Fisher's Exact Test for Count Data `

` data: data `

` p-value = 0.00001568`

` alternative hypothesis: greater `

- SOCR Calculations

Translate this page: