# SOCR EduMaterials AnalysisActivities Fisher Exact

(Difference between revisions)
 Revision as of 18:18, 25 August 2007 (view source)Annie (Talk | contribs) (→SOCR Analyses Example on Fisher's Exact Test)← Older edit Current revision as of 19:34, 22 June 2010 (view source)IvoDinov (Talk | contribs) (→Example) (12 intermediate revisions not shown) Line 1: Line 1: - === SOCR Analyses Example on Fisher's Exact Test === + == [[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 example is based on the data taken from "Mathematical Statistics and Data Analysis" by John A. Rice, Second Edition, Ducbury Press, 1995. + ===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:''' + ===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. - -
[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig1.gif|700px]]
[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig1.gif|700px]]
-
[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig1A.gif|450px]]
[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig1A.gif|450px]]
- + '''2.'''  Click on "'''Input'''" button. You'll see a screen like below waiting for your input - '''2.'''  Click on "'''Example 1'''" button. than the "Data" button to see the data. +
[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig2.gif|700px]]
[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig2.gif|700px]]
- '''3.''' The data need to be send to the computer for analysis. Click on the "Mapping" button to include the groups you want. + 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.)
[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig2A.gif|700px]]
[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig2A.gif|700px]]
- '''4.''' Click on the "'''Calculate'''" button to enter number of parameters. For example, for a Poisson model, you should enter '1' for that Poisson model has 1 parameter. If you don't enter any number, the default used is 0. + 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. -
[[Image:SOCR_AnalysisActivities_ChiTable_Chu_061407_Fig2B.gif|700px]]
+ - You'll see a message like below if you don't type in any number. +
[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig2B.gif|700px]]
-
[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig2C.gif|700px]]
+ - '''5.''' Now you're ready to see the results. Just click on the "Result" button. + '''3.''' Click on the "'''Calculate'''" button and then "'''Result'''" to see the results. +
[[Image:SOCR_AnalysisActivities_ChiTable_Chu_061407_Fig3.gif|700px]]
-
[[Image:SOCR_AnalysisActivities_FisherExact_Chu_061407_Fig3.gif|700px]]
+ '''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). - If you'd like to include some other group(s) or remove the current groups and start over, simply go to the '''Mapping''' button and take the groups you want. + * 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 [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]. - '''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 reteive the data by click an '''EXAMPLE''' button. + * 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). + > 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 +
[[Image:SOCR_AnalysisActivities_FishersExactTest_Fig4.png|500px]]
-
{{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}}

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

### 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 po, 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!

### 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 