Announcement

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

  • How to get p-value from z statistic

    Good Morning,

    I am a novice STATA user hence kindly bare with me if my question is basic. I executed the following commands:

    Code:
    mhodds tb hiv2 if missing==0, by(bmigrp) c(1,0)
    
    Maximum likelihood estimate of the odds ratio
    Comparing hiv2==1 vs. hiv2==0
    by bmigrp
    
    -------------------------------------------------------------------------------
       bmigrp | Odds Ratio        chi2(1)         P>chi2       [95% Conf. Interval]
    ----------+--------------------------------------------------------------------
          <19 |   8.000000          16.53         0.0000         2.42589   26.38208
        19-24 |   2.311694           5.60         0.0179         1.13161    4.72239
          25+ |   3.213415           3.89         0.0486         0.94169   10.96542
    -------------------------------------------------------------------------------
    
        Mantel-Haenszel estimate controlling for bmigrp
        ----------------------------------------------------------------
         Odds Ratio    chi2(1)        P>chi2        [95% Conf. Interval]
        ----------------------------------------------------------------
           3.256096      21.22        0.0000         1.912757   5.542868
        ----------------------------------------------------------------
    
    Test of homogeneity of ORs (approx): chi2(2)   =    3.22
                                         Pr>chi2   =  0.1996
    I would like to get the Pr>chi2 value 0.1996 and populate it into an excel cell but am facing difficulties. The return list command does not show the actual Pr>chi2 value but shows I think the z score (i.e. r(chi2_hom))

    Code:
    . return list
    
    scalars:
                     r(or) =  2.796406651543788
                  r(lb_or) =  1.71732962901426
                  r(ub_or) =  4.55351729142816
                   r(chi2) =  18.64835958570303
                      r(p) =  .0000157182454007
                 r(df_hom) =  1
               r(chi2_hom) =  .068043938660382
    Any help will be greatly appreciated.

    Thanks,

    Paul

  • #2
    You're better off posting questions like this over in the main Stata forum. This one's for Mata-related questions.

    Anyway,
    Code:
    display in smcl as result %06.4f chi2tail(r(df_hom), r(chi2_hom))
    is probably what you're looking for.
    Code:
    help chi2tail()
    for more information.

    Comment


    • #3
      Hi Joseph,

      Am new to this forum, nevertheless I have taken note of your guidance. Thanks for you help, your code worked, very much appreciated.

      Thanks,

      Paul

      Comment

      Working...
      X