Announcement

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

  • How to get more digits to display for the p-value

    Hi,

    Does someone know how to get Stata to display more than just three digits for the p-value?

    Normally Stata reports that the p-value is .001 or .000 (for example), but my supervisor would like to see more digits (or the exact p-value).

    I don't want to alter how the data is produced, of course. I only want Stata to display more digits for p-values I am interested in.

    Is there a post-estimation command I can use?

    Context: I am running paired samples ttests. Stata command: ttest var2 - var1, level(95)

    Thanks!

  • #2
    Code:
    . webuse fuel, clear
    
    . ttest mpg1 == mpg2
    
    Paired t test
    ------------------------------------------------------------------------------
    Variable |     Obs        Mean    Std. err.   Std. dev.   [95% conf. interval]
    ---------+--------------------------------------------------------------------
        mpg1 |      12          21    .7881701    2.730301    19.26525    22.73475
        mpg2 |      12       22.75    .9384465    3.250874    20.68449    24.81551
    ---------+--------------------------------------------------------------------
        diff |      12       -1.75    .7797144     2.70101    -3.46614   -.0338602
    ------------------------------------------------------------------------------
         mean(diff) = mean(mpg1 - mpg2)                               t =  -2.2444
     H0: mean(diff) = 0                              Degrees of freedom =       11
    
     Ha: mean(diff) < 0           Ha: mean(diff) != 0           Ha: mean(diff) > 0
     Pr(T < t) = 0.0232         Pr(|T| > |t|) = 0.0463          Pr(T > t) = 0.9768
    
    . ret li
    
    scalars:
                  r(level) =  95
                   r(sd_2) =  3.250874008352495
                   r(sd_1) =  2.73030134866931
                     r(se) =  .7797143999276566
                    r(p_u) =  .976829175701198
                    r(p_l) =  .023170824298802
                      r(p) =  .046341648597604
                      r(t) =  -2.244411543716993
                   r(df_t) =  11
                   r(mu_2) =  22.75
                    r(N_2) =  12
                   r(mu_1) =  21
                    r(N_1) =  12
    
    .

    Code:
     
    
    search buis, author
    yields (among other papers)



    Code:
    SJ-14-1 st0332  . . . . . .  Stata tip 116: Where did my p-values go? (Part 3)
            . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . M. L. Buis
            Q1/14   SJ 14(1):218--220                                (no commands)
            discusses how to recover the standard errors for back-
            transformed parameters (standard deviation and correlation)
    
    SJ-12-4 st0280  . . . . . .  Stata tip 112: Where did my p-values go? (Part 2)
            . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . M. L. Buis
            Q4/12   SJ 12(4):759--760                                (no commands)
            shows how p-values can be recovered for other tests that
            are sometimes displayed by estimation commands
    
    SJ-7-4  st0137  . . . . . . . . . . .  Stata tip 53: Where did my p-values go?
            . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . M. L. Buis
            Q4/07   SJ 7(4):584--586                                 (no commands)
            tip on calculating the t statistic, p-values, and
            confidence intervals using returned results
    Last edited by Nick Cox; 08 Feb 2023, 12:36.

    Comment


    • #3
      The usual answer to such queries is to look at the help file, specifically at the end, under the "Stored Results" section. This tells all of the macros, scalars and matrices that may be returned as r-class (for general commands) or e-class (for estimation commands) results, typically. More information about this can be found in -help stored results-. From -help ttest-, the two-sided p-value is returned in -r(p)-.

      You can view the contents with either of the following commands, according to taste.

      Code:
      display %12.5g r(p)
      display r(p)
      return list  // for r-class results only
      ereturn list // for e-class results only

      Comment


      • #4
        you can also get more digits in your standard output; see
        Code:
        h pformat

        Comment


        • #5
          Thank you, all! I was also shown this package:

          ssc install groups

          And after running your test, you can run this syntax to return the exact values:

          return list (return list or ret li)

          Comment

          Working...
          X