Announcement

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

  • Does Pcorr not store significance values of partial correlations?

    Hi there,

    It's been a while since I posted a question here - apologize if I've forgotten (missed) some of the norms. I am writing to ask if the function "pcorr" really does not store the significance values of the partial correlations in matrices? The help file lists just the following as being part of the stored results.

    pcorr stores the following in r():

    Scalars
    r(N) number of observations
    r(df) degrees of freedom

    Matrices
    r(p_corr) partial correlation coefficient vector
    r(sp_corr) semipartial correlation coefficient vector

    Am I missing something obvious? Thanks for your help!

    Best,
    Maithreyi

  • #2
    Isn't the p-value simply the p-value from the underlying regression model?

    To elaborate using an example:

    Code:
    . sysuse auto
    (1978 automobile data)
    
    . pcorr price mpg turn gear_ratio
    (obs=74)
    
    Partial and semipartial correlations of price with
    
                   Partial   Semipartial      Partial   Semipartial   Significance
       Variable |    corr.         corr.      corr.^2       corr.^2          value
    ------------+-----------------------------------------------------------------
            mpg |  -0.3497       -0.3288       0.1223        0.1081         0.0026
           turn |  -0.0662       -0.0585       0.0044        0.0034         0.5804
     gear_ratio |  -0.0607       -0.0535       0.0037        0.0029         0.6127
    
    . regress price mpg turn gear_ratio , noheader pformat(%5.4f)
    ------------------------------------------------------------------------------
           price | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             mpg |  -249.3979   79.86385    -3.12   0.0026    -408.6813   -90.11447
            turn |  -62.36816   112.2961    -0.56   0.5804    -286.3358    161.5994
      gear_ratio |  -485.7191   955.1604    -0.51   0.6127    -2390.727    1419.288
           _cons |   15413.95   6887.792     2.24   0.0284      1676.68    29151.22
    ------------------------------------------------------------------------------
    The p-values are stored in r(table) after regress.They are also easily re-calculated (see Buis, 2007).


    Buis, M. 2007. Stata tip 53: Where did my p-values go? The Stata Journal, 7(4), 584–586
    Last edited by daniel klein; 17 Oct 2023, 15:12.

    Comment


    • #3
      Thank you, daniel! In this case, I just needed the correlation coefficient and p-values for a large number of variables. So, I was hoping to directly pull those from the stored matrices. I suppose I could just run the underlying regression and back-calculate the correlation coefficient from the betas and p-values from r(table). I just found it odd though as it would have been wonderful to have r(sig) stored in the case of pcorr too just like with pwcorr! Thank you again!

      Comment


      • #4
        You could probably modify pcorr.ado accoringly. Or, you can set up a wrapper:

        Code:
        program pcorr_sig , rclass
            
            version 17
            
            syntax varlist
            
            quietly regress `varlist'
            
            tempname p
            matrix `p' = r(table)[4, 1..e(df_m)]'
            
            pcorr `varlist'
            
            return matrix sig = `p'
            
            return add
            
        end

        Here is an example:

        Code:
        . pcorr_sig price turn mpg gear_ratio
        (obs=74)
        
        Partial and semipartial correlations of price with
        
                       Partial   Semipartial      Partial   Semipartial   Significance
           Variable |    corr.         corr.      corr.^2       corr.^2          value
        ------------+-----------------------------------------------------------------
               turn |  -0.0662       -0.0585       0.0044        0.0034         0.5804
                mpg |  -0.3497       -0.3288       0.1223        0.1081         0.0026
         gear_ratio |  -0.0607       -0.0535       0.0037        0.0029         0.6127
        
        .
        . return list
        
        scalars:
                         r(df) =  70
                          r(N) =  74
        
        matrices:
                    r(sp_corr) :  3 x 1
                     r(p_corr) :  3 x 1
                        r(sig) :  3 x 1
        
        .
        . matlist r(sig)
        
                     |    pvalue
        -------------+-----------
                turn |  .5803986
                 mpg |  .0026049
          gear_ratio |   .612687

        Note that the wrapper is just a proof of concept. It does not handle factor variables, omitted variables (due to collinearity), etc. Do not use it blindly.

        Comment


        • #5
          Yayy - thank you so much daniel! This is great.

          Comment

          Working...
          X