Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Fisher's exact test - no output shown

    I have a simple 2x2 contingency table wherein one column totals zero.

    Can anyone help me understand why Stata shows no output for Fisher's exact test when the following command made?

    Code:
    tabi 0 7 \ 0 8, exact
    Most online calculators show the two-tailed p-value for this example as 1.00, but for some reason Stata gives no p-value whatsoever.

  • #2
    you say you have a 2x2 table but you only show us 2 numbers - please clarify as -tabi- requires a minimum of 4 numbers - if these are proportions, then you probably want a different test anyway

    Comment


    • #3
      Per the tabi command above, the table looks like this:
      0 7
      0 8
      Again, just wondering why Stata does not seem to compute the r(p_exact) stored value when the command above is run.

      Comment


      • #4
        We see that tabi (and for that matter tab2) drops from the table any rows or columns with no observations. Note that the output of tabi is
        Code:
        tabi 0 7 \ 0 8, exact
        
                   |    col
               row |         2 |     Total
        -----------+-----------+----------
                 1 |         7 |         7 
                 2 |         8 |         8 
        -----------+-----------+----------
             Total |        15 |        15
        which does not show col==1 with zeroes in each row.

        Comment


        • #5
          Originally posted by Dan Palmer View Post
          Per the tabi command above, the table looks like this:
          0 7
          0 8
          Again, just wondering why Stata does not seem to compute the r(p_exact) stored value when the command above is run.
          Perhaps because statisticians recognize this p-value ought to be 1, and it's uncommon to encounter such a scenario.

          Consider the one-sided formula to compute the p-value for Fisher's exact test in with a 2x2 table. The p-value arises from the hypergeometric distribution by assuming the marginal totals are fixed.
          Group 1 Group 2 Row Total
          Category 1 a b a+b
          Category 2 c d c+d
          Column Total a+c b+d n = a + b + c + d
          Code:
          p = (a+b)!(c+d)!(a+c)!(b+d)! / (a!b!c!d!n!)
          So a and c are both zero. That reduces the equation above to p = (b!d!(b+d)!) / (b!d!(b+d)!) = 1.
          Last edited by Leonardo Guizzetti; 21 Dec 2021, 20:40.

          Comment


          • #6
            Ok, thanks to both of you. It would be nice if Stata still would produce the r(p_exact) stored value even if is assured of being 1.00 by definition.

            Comment


            • #7
              In principle #6 is a perfectly understandable request, but it's harder than you might hope. For one, tabi is just a wrapper for tabulate and tabulate's wired-in design is not to show a row or column that doesn't exist in the data.. Indeed it's quite hard work to get around that, as in general you have to specify what might exist.

              Still, the request is for StataCorp and I would add it to the Stata 18 wish list here.

              Comment


              • #8
                There's also the question of whether the pvalue has any validity in such a case, because you don't really have a valid 2x2 table when an entire column or row is zero. Fisher's test is ok when there's one empty cell, but I believe the assumption is that there's at least one observation in each marginal total.

                I suspect StataCorp feels it is invalid, or should be a prompt to the user to consider a different test or approach, and this is my own speculation of course.

                Comment

                Working...
                X