Announcement

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

  • How can I see the stars in the correlation table in a single table?

    Hi there; I have a question about the correlation command in Stata.

    When doing correlation analysis in stata, is there a command where I can see ***,**,* symbols representing significance at 1,5 and 10% level in a single table?

    Currently, I have to write the following commands separately and then combine the stars in these tables into a single table.
    pwcor.......,star(1)
    pwcor.......,star(5)
    pwcor.......,star(10)

  • #2
    asdoc pwcorr x y, star(all)

    Comment


    • #3
      the correlation command in Stata
      There's no such thing. There's correlate, pwcorr [sic], and any number of other official and community-contributed commands with varying focus on correlations,

      As you've found pwcorr does some of what you want. Its lack of support for what you want could arise from a principle that working with multiple thresholds at once is incoherent, for all that it is common, or from a principle that if you want inferential results in terms of significance, then it's better to work with P-values directly.

      That's speculation about official commands.

      I can tell you that the community-contributed command corrci from the Stata Journal while shrinking back in modified horror from this starring, as if correlations were like restaurants or movies or things you bought on a website, does support confidence intervals. However, users are expected to add their own circumspection according to whatever issues of sampling, dependence structure and marginal or joint distributions might compromise the accuracy and relevance of such intervals.

      Here's some token code. It produces all the information you need for the display you want, but not the code to get the display you want.

      Code:
      . sysuse auto, clear
      (1978 automobile data)
      
      . ds
      make          mpg           headroom      weight        turn          gear_ratio
      price         rep78         trunk         length        displacement  foreign
      
      . corrci mpg-gear_ratio
      
      (obs=69)
      
                                 correlations and 95% limits
      mpg          rep78             0.402    0.183    0.583
      mpg          headroom         -0.400   -0.581   -0.180
      mpg          trunk            -0.580   -0.718   -0.398
      mpg          weight           -0.806   -0.875   -0.703
      mpg          length           -0.804   -0.874   -0.700
      mpg          turn             -0.735   -0.828   -0.604
      mpg          displacement     -0.743   -0.833   -0.615
      mpg          gear_ratio        0.657    0.497    0.773
      rep78        headroom         -0.148   -0.372    0.092
      rep78        trunk            -0.157   -0.380    0.083
      rep78        weight           -0.400   -0.582   -0.181
      rep78        length           -0.361   -0.550   -0.135
      rep78        turn             -0.496   -0.656   -0.294
      rep78        displacement     -0.412   -0.591   -0.194
      rep78        gear_ratio        0.410    0.192    0.590
      headroom     trunk             0.661    0.503    0.776
      headroom     weight            0.479    0.274    0.643
      headroom     length            0.524    0.328    0.677
      headroom     turn              0.435    0.221    0.609
      headroom     displacement      0.476    0.270    0.641
      headroom     gear_ratio       -0.379   -0.565   -0.156
      trunk        weight            0.669    0.514    0.782
      trunk        length            0.733    0.600    0.826
      trunk        turn              0.601    0.424    0.733
      trunk        displacement      0.629    0.461    0.753
      trunk        gear_ratio       -0.511   -0.667   -0.312
      weight       length            0.948    0.917    0.967
      weight       turn              0.861    0.784    0.912
      weight       displacement      0.932    0.892    0.957
      weight       gear_ratio       -0.791   -0.865   -0.681
      length       turn              0.863    0.787    0.913
      length       displacement      0.862    0.786    0.913
      length       gear_ratio       -0.723   -0.820   -0.587
      turn         displacement      0.812    0.713    0.880
      turn         gear_ratio       -0.701   -0.804   -0.556
      displacement gear_ratio       -0.838   -0.897   -0.750
      
      
      . corrci mpg-gear_ratio, saving(results) saven savepvalue
      
      (obs=69)
      
                                 correlations and 95% limits
      mpg          rep78             0.402    0.183    0.583
      mpg          headroom         -0.400   -0.581   -0.180
      mpg          trunk            -0.580   -0.718   -0.398
      mpg          weight           -0.806   -0.875   -0.703
      mpg          length           -0.804   -0.874   -0.700
      mpg          turn             -0.735   -0.828   -0.604
      mpg          displacement     -0.743   -0.833   -0.615
      mpg          gear_ratio        0.657    0.497    0.773
      rep78        headroom         -0.148   -0.372    0.092
      rep78        trunk            -0.157   -0.380    0.083
      rep78        weight           -0.400   -0.582   -0.181
      rep78        length           -0.361   -0.550   -0.135
      rep78        turn             -0.496   -0.656   -0.294
      rep78        displacement     -0.412   -0.591   -0.194
      rep78        gear_ratio        0.410    0.192    0.590
      headroom     trunk             0.661    0.503    0.776
      headroom     weight            0.479    0.274    0.643
      headroom     length            0.524    0.328    0.677
      headroom     turn              0.435    0.221    0.609
      headroom     displacement      0.476    0.270    0.641
      headroom     gear_ratio       -0.379   -0.565   -0.156
      trunk        weight            0.669    0.514    0.782
      trunk        length            0.733    0.600    0.826
      trunk        turn              0.601    0.424    0.733
      trunk        displacement      0.629    0.461    0.753
      trunk        gear_ratio       -0.511   -0.667   -0.312
      weight       length            0.948    0.917    0.967
      weight       turn              0.861    0.784    0.912
      weight       displacement      0.932    0.892    0.957
      weight       gear_ratio       -0.791   -0.865   -0.681
      length       turn              0.863    0.787    0.913
      length       displacement      0.862    0.786    0.913
      length       gear_ratio       -0.723   -0.820   -0.587
      turn         displacement      0.812    0.713    0.880
      turn         gear_ratio       -0.701   -0.804   -0.556
      displacement gear_ratio       -0.838   -0.897   -0.750
      
      . use results
      
      . l
      
           +---------------------------------------------------------------------------------+
           |         var1           var2           r       lower       upper    n     pvalue |
           |---------------------------------------------------------------------------------|
        1. |          mpg          rep78    .4023404    .1830951    .5834604   69   .0006101 |
        2. |          mpg       headroom   -.3995853    -.581291   -.1799205   69   .0006703 |
        3. |          mpg          trunk   -.5798199   -.7179717   -.3977191   69   1.78e-07 |
        4. |          mpg         weight   -.8055198   -.8753199   -.7028354   69   7.10e-17 |
        5. |          mpg         length   -.8036763   -.8740919   -.7001802   69   9.43e-17 |
           |---------------------------------------------------------------------------------|
        6. |          mpg           turn   -.7354584   -.8280087   -.6038975   69   6.16e-13 |
        7. |          mpg   displacement   -.7433629   -.8334132   -.6148606   69   2.57e-13 |
        8. |          mpg     gear_ratio    .6565194    .4970773    .7730754   69   9.08e-10 |
        9. |        rep78       headroom   -.1479982   -.3716602    .0919017   69   .2248995 |
       10. |        rep78          trunk   -.1572433   -.3797896     .082508   69   .1969316 |
           |---------------------------------------------------------------------------------|
       11. |        rep78         weight   -.4003441   -.5818887   -.1807944   69   .0006532 |
       12. |        rep78         length   -.3605655   -.5502855   -.1354434   69   .0023388 |
       13. |        rep78           turn   -.4961308    -.655804   -.2939693   69   .0000146 |
       14. |        rep78   displacement   -.4119429   -.5910016   -.1941961   69   .0004367 |
       15. |        rep78     gear_ratio      .41034    .1923392    .5897449   69    .000462 |
           |---------------------------------------------------------------------------------|
       16. |     headroom          trunk    .6607842    .5027275    .7760886   69   6.47e-10 |
       17. |     headroom         weight    .4794664    .2738639    .6431609   69   .0000307 |
       18. |     headroom         length    .5239663    .3279564    .6767246   69   3.83e-06 |
       19. |     headroom           turn    .4346856    .2207121    .6087382   69   .0001898 |
       20. |     headroom   displacement    .4762977    .2700611    .6407467   69   .0000352 |
           |---------------------------------------------------------------------------------|
       21. |     headroom     gear_ratio   -.3790486   -.5650378    -.156399   69   .0013188 |
       22. |        trunk         weight     .669138    .5138342    .7819756   69   3.28e-10 |
       23. |        trunk         length    .7325796     .599917     .826036   69   8.40e-13 |
       24. |        trunk           turn    .6007946    .4244724    .7332147   69   4.82e-08 |
       25. |        trunk   displacement    .6286966    .4605452    .7532878   69   7.28e-09 |
           |---------------------------------------------------------------------------------|
       26. |        trunk     gear_ratio   -.5106986   -.6667835    -.311693   69   7.35e-06 |
       27. |       weight         length    .9478298    .9168227    .9674741   69   5.54e-35 |
       28. |       weight           turn    .8610226    .7841397    .9118747   69   2.37e-21 |
       29. |       weight   displacement    .9316212    .8915171    .9572347   69   3.68e-31 |
       30. |       weight     gear_ratio   -.7906038   -.8653582   -.6814334   69   6.51e-16 |
           |---------------------------------------------------------------------------------|
       31. |       length           turn    .8630964    .7872295    .9132251   69   1.49e-21 |
       32. |       length   displacement    .8620638    .7856905    .9125528   69   1.88e-21 |
       33. |       length     gear_ratio    -.723173   -.8195745   -.5869564   69   2.26e-12 |
       34. |         turn   displacement    .8123749    .7127342    .8798784   69   2.40e-17 |
       35. |         turn     gear_ratio   -.7005151    -.803909    -.556022   69   2.08e-11 |
           |---------------------------------------------------------------------------------|
       36. | displacement     gear_ratio   -.8380556   -.8968456   -.7501729   69   2.70e-19 |
           +---------------------------------------------------------------------------------

      Comment

      Working...
      X