Announcement

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

  • Extract p-value of independent variable ologit

    Hello,

    I am trying to extract the p-value of an independent variable after an ologit. It seems like independent variable-specific results from ologit are not stored (like for anova), but I would just like to double-check this with someone who is more skilled in Stata than I am.

    For demonstration, here are the first 20 lines of my data (removed decimals), with the ologit:

    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float(dv iv1 iv2)
    23 6 27
    21 7 40
    20 6 55
    20 6 64
    21 7 44
    22 7 24
    18 7 57
    24 7 41
    22 7 30
    21 6 29
    18 7 32
    22 5 39
    24 7 37
    19 6 29
    22 7 28
    21 6 52
    23 6 58
    23 7 58
    19 6 68
    23 7 30
    end
    ologit dv c.iv1##c.iv2
    I want to extract the p-value for the iv1 x iv2 interaction (which is 0.911) in a scalar to be used for another purpose.

    Is this possible, and if yes, how?

    Thanks so much!
    Last edited by Rob Henst; 16 Nov 2019, 15:18. Reason: I specified that iv1 and iv2 are continuous variables: ologit dv iv1##iv2 --> ologit dv c.iv1##c.iv2

  • #2
    I'm not sure exactly which p-value you want as 0.911 does not appear in the results using your example; however, try this:
    Code:
    mat li r(table)
    to find the right value and then extract it; one easy way is through the "el()" function; see
    Code:
    help el()
    note that r(table) disappears if you do any other estimations so you might want to first save it under a different name

    Comment


    • #3
      Thanks so much for your reply Rich!

      About the 0.911 p-value: I forgot to specify that iv1 and iv2 are continuous variables. I edited my initial post to correct this. I can confirm that the p-value 0.911 is now generated for c.iv1#v.iv2.

      Following your instructions:

      Code:
      . mat li r(table)
      
      r(table)[9,9]
                      dv:         dv:         dv:          /:          /:          /:          /:          /:          /:
                                           c.iv1#                                                                        
                     iv1         iv2       c.iv2        cut1        cut2        cut3        cut4        cut5        cut6
           b   -.0024388  -.08008121   .00744392  -3.7369584  -2.9126953   -2.310842  -1.3341333  -.43593837   .92710246
          se   2.6760532   .42309081   .06690812   17.253729   17.256408   17.234149   17.215827   17.211381   17.185304
           z  -.00091134  -.18927664   .11125586          .b          .b          .b          .b          .b          .b
      pvalue   .99927285     .849876   .91141345          .b          .b          .b          .b          .b          .b
          ll  -5.2474067  -.90932395  -.12369358  -37.553645  -36.734633  -36.089153  -35.076535  -34.169625  -32.755474
          ul   5.2425291   .74916154   .13858142   30.079729   30.909242   31.467469   32.408268   33.297748   34.609679
          df           .           .           .           .           .           .           .           .           .
        crit    1.959964    1.959964    1.959964    1.959964    1.959964    1.959964    1.959964    1.959964    1.959964
       eform           0           0           0           0           0           0           0           0           0
      
      
      . display el(r(table), 4,3)
      .91141345
      I got exactly what I needed. Thank you so much for your quick reply and solution.

      Comment


      • #4
        Possibly easier, because it doesn't require you to get the matrix coordinates right:


        Code:
        . testparm c.iv1#c.iv2
        
         ( 1)  [dv]c.iv1#c.iv2 = 0
        
                   chi2(  1) =    0.01
                 Prob > chi2 =    0.9114
        
        . return list
        
        scalars:
                       r(drop) =  0
                       r(chi2) =  .0123778670945305
                         r(df) =  1
                          r(p) =  .9114134541215821
        -------------------------------------------
        Richard Williams, Notre Dame Dept of Sociology
        StataNow Version: 18.5 MP (2 processor)

        EMAIL: [email protected]
        WWW: https://www3.nd.edu/~rwilliam

        Comment


        • #5
          Thanks Richard, now I have two solutions.

          I think the benefit of your solution is that it is safer in to-do files where multiple ologit's with changing numbers of independent variables are used. Your solution would always select the correct one, because you specify the varname.

          Rich's solution requires fewer steps, and is therefore easier to use as long as the number and order of independent variables does not change (i.e. if the coordinates don't need to be changed).

          Many thanks for your answers, Rich and Richard!

          Comment

          Working...
          X