Announcement

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

  • Is it possible to have 0 p-value when using chi-square test?

    Hello,

    I am having difficulty interpreting the results I have.

    I want to check whether the probability of A and the probability of B are independent or not.

    Below is the code and the result I have.


    . tab exttot_wo_motor extdur_wo_motor, chi2

    exttot_wo_ | extdur_wo_motor
    motor | 0 1 | Total
    -----------+----------------------+----------
    0 | 16,486 7,446 | 23,932
    1 | 8,520 16,652 | 25,172
    -----------+----------------------+----------
    Total | 25,006 24,098 | 49,104

    Pearson chi2(1) = 6.0e+03 Pr = 0.000

    .
    end of do-file


    As far as I know, Pr is the p-value so, I thought since the p-value is close to 0 I can reject the null hypothesis and argue that Pr(exttot_wo_motor) and Pr(extdur_wo_motor) are not independent


    However, when I also run as below.

    . return list

    scalars:
    r(N) = 49104
    r(r) = 2
    r(c) = 2
    r(chi2) = 6027.114958488087
    r(p) = 0

    Then, r(p) gives me 0.

    I am a bit confused because I have never seen any case with a p-value equal to 0 exactly.

    So I was wondering whether I am understanding something wrong.

    Thanks in advance.

  • #2
    It's not that your p-value is zero, but rather is so small it is below the level of machine precision as to be effectively zero (to a computer). The real value is of course slightly bigger than zero. The below code reproduces the p-value calculation for the chi2 test.

    Code:
    input byte(row col) int(count)
    0 0 16486
    0 1 7446
    1 0 8520
    1 1 16652
    end
    
    tab row col [fw=count], chi2
    di %15.0g chi2tail((`r(r)'-1)*(`r(c)'-1), `r(chi2)')
    You can compare this with small cell counts to see the same calculation with a noticeably larger p-value.

    Comment


    • #3
      Thank you very much.

      Comment

      Working...
      X