Announcement

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

  • individual p-values- chi square test

    Hi

    I used the simple chi square test command, tab var1 var2, chi2. It gives the overall p-value (0.000)

    What command should I use in order to get the individual p-value of "No group" & the p-value of "Yes"group. (i.e. as below)



    | Unknown Highest D High Disa Moderate Less Disa Least Dis | Total
    -----------+------------------------------------------------------------------+----------
    No | 56 658 634 564 537 553 | 3,002
    Yes | 5 900 869 883 797 848 | 4,302
    -----------+------------------------------------------------------------------+----------
    Total | 61 1,558 1,503 1,447 1,334 1,401 | 7,304

    Pearson chi2(5) = 70.9560 Pr = 0.000


    Thanks



  • #2
    Such P-values are, as a matter of principle, not defined. Separate P-values for each row are only defined with a test of a different hypothesis for that row alone.

    Comment


    • #3
      Perhaps I didn't get the point in #1.

      However, shall it be the chi-square goodness of fit test, where say, one wishes to "test"he distribution of a variable (under a "if" clause") , I wonder whether we could consider the "no" group under a univariate frequency distribution.

      If so ( and I'm not absolutely sure about that), the SJ/STB - tab_chi - (Nick Cox) might provide what Ching wishes:

      Code:
      . set obs 6
      number of observations (_N) was 6, now 6
      
      . input race sex freq
      
                race        sex       freq
        1. 0 0 12
        2. 0 1 84
        3. 1 0 11
        4. 1 1 13
        5. 2 0 14
        6. 2 1 11
      
      . label define race 0 "White" 1 "Black" 2 "Other"
      
      . label define sex 0 "Female" 1 "Male"
      
      . label values sex sex
      
      . label values race race
      
      . expand freq
      (139 observations created)
      
      . tab sex race, chi2
      
                 |               race
             sex |     White      Black      Other |     Total
      -----------+---------------------------------+----------
          Female |        12         11         14 |        37 
            Male |        84         13         11 |       108 
      -----------+---------------------------------+----------
           Total |        96         24         25 |       145 
      
                Pearson chi2(2) =  25.9934   Pr = 0.000
      
      . chitest race if sex ==1
      
      Chi-square test:
          observed frequencies from race
          expected frequencies equal
      
               Pearson chi2(107) = 140.8857   Pr =  0.016
      likelihood-ratio chi2(107) = 109.3733   Pr =  0.418
      
                                                 residuals
           +-------------------------------------------------+
           | observed   expected   notes   classic   Pearson |
           |-------------------------------------------------|
        1. |        0      0.324      **    -0.324    -0.569 |
        2. |        1      0.324      **     0.676     1.187 |
        3. |        2      0.324      **     1.676     2.944 |
        4. |        0      0.324      **    -0.324    -0.569 |
        5. |        0      0.324      **    -0.324    -0.569 |
           |-------------------------------------------------|
        6. |        0      0.324      **    -0.324    -0.569 |
        7. |        0      0.324      **    -0.324    -0.569 |
        8. |        0      0.324      **    -0.324    -0.569 |
        9. |        0      0.324      **    -0.324    -0.569 |
       10. |        0      0.324      **    -0.324    -0.569 |
           |-------------------------------------------------|
        (output omitted)
           |-------------------------------------------------|
      101. |        2      0.324      **     1.676     2.944 |
      102. |        2      0.324      **     1.676     2.944 |
      103. |        2      0.324      **     1.676     2.944 |
      104. |        2      0.324      **     1.676     2.944 |
      105. |        2      0.324      **     1.676     2.944 |
           |-------------------------------------------------|
      106. |        2      0.324      **     1.676     2.944 |
      107. |        2      0.324      **     1.676     2.944 |
      108. |        2      0.324      **     1.676     2.944 |
           +-------------------------------------------------+
      
      ** 0 <  expected < 1
      I hope to have helped. Shall this strategy be incorrect, I also hope to learn from that.

      Best,

      Marcos
      Best regards,

      Marcos

      Comment


      • #4
        Editing the second part of the previous messsage:

        Code:
        . set obs 3
        number of observations (_N) was 0, now 3
        
        . input male
        
                  male
          1. 84
          2. 13
          3. 11
        
        . chitest male
        
        Chi-square test:
            observed frequencies from male
            expected frequencies equal
        
                 Pearson chi2(2) =  96.0556   Pr =  0.000
        likelihood-ratio chi2(2) =  89.7795   Pr =  0.000
        
                                           residuals
             +-----------------------------------------+
             | observed   expected   classic   Pearson |
             |-----------------------------------------|
          1. |       84     36.000    48.000     8.000 |
          2. |       13     36.000   -23.000    -3.833 |
          3. |       11     36.000   -25.000    -4.167 |
        Best regards,

        Marcos

        Comment


        • #5
          Marcos: Your posts and mine (#2) are consistent. You could test each row of the table against a hypothesis of equal frequencies, or any other hypothesis about those frequencies alone. Somehow I doubt this is the question, but the OP has not returned to the thread.

          For the record tab_chi is available from SSC. It has never been published through the STB or Stata Journal.

          Comment


          • #6
            Thanks for the feedback Nick! Also, thanks for the correction on the source (SSC) of tab_chi.

            Below, the "reason" I thought it was SJ/STB. Due to discraction, I just read the information on the first line:

            2 packages found (Stata Journal and STB listed first)
            -----------------------------------------------------

            tab_chi from http://www.stata.com/users/njc
            tab_chi Tabulation and chi-square test programs. / Programs by Nicholas J.
            Cox, Durham University <[email protected]>. / Statalist distribution,
            22 March 1999. / See help tab_chi

            tab_chi from http://fmwww.bc.edu/RePEc/bocode/t
            'TAB_CHI': modules for tabulation of multiple variables in Stata 8.2 or
            better / chitest and chitesti carry out chi-square tests for univariate /
            frequency distributions. chitesti is the immediate command / version of
            chitest. Both require Stata 8.2; earlier versions are / available as
            Last edited by Marcos Almeida; 29 Nov 2016, 06:52.
            Best regards,

            Marcos

            Comment


            • #7
              Indeed. I didn't mention the prehistoric version on the Stata website itself. But (e.g.) results like that below (truncated) imply that anyone watching with Stata 5 should download from there.

              Code:
              . type http://www.stata.com/users/njc/tab_chi/chitest.ado
              *! 1.4.4 NJC 26 January 1999
              * 1.4.3  2 Sept 1997
              * 1.4.2  13 August 1997
              * 1.4.2, 1.4.3 indicate keyboard entry (undocumented option)
              * 1.4.1  30 April 1997     save emean in S_7
              * 1.4.0  20 December 1996
              program def chitest
                  version 5.0

              Comment

              Working...
              X