Announcement

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

  • Is that possible to output correlation coefficient above a cutoff?

    For example, output the coefficient above .7 to a table, can we do this? can command estout do this?
    I searched and found no answers. Thanks a ton!

  • #2
    estout is from SSC, as you are asked to explain (FAQ Advice #12).

    Code:
    sysuse auto, clear
    pwcorr price headroom mpg displacement
    
    quietly estpost corr price headroom mpg displacement, matrix
    esttab ., replace b(3) unstack nonum nomtitle not noobs ///
    label compress eqlabels((1) (2) (3) (4), lhs("Variables")) ///
    nostar transform(((abs(@)>0.7)*@)) substitute("0.000" "     ")  
    Res.:

    Code:
    . pwcorr price headroom mpg displacement
    
                 |    price headroom      mpg displa~t
    -------------+------------------------------------
           price |   1.0000 
        headroom |   0.1145   1.0000 
             mpg |  -0.4686  -0.4138   1.0000 
    displacement |   0.4949   0.4745  -0.7056   1.0000 
    
    . 
    . quietly estpost corr price headroom mpg displacement, matrix
    
    . esttab ., replace b(3) unstack nonum nomtitle not noobs ///
    > label compress eqlabels((1) (2) (3) (4), lhs("Variables")) ///
    > nostar transform(((abs(@)>0.7)*@)) substitute("0.000" "     ")  
    
    --------------------------------------------------------
    Variables              (1)       (2)       (3)       (4)
    --------------------------------------------------------
    Price                1.000                              
    Headroom (in.)                 1.000                    
    Mileage (mpg)                            1.000          
    Displacem.. in.)                        -0.706     1.000
    --------------------------------------------------------

    Comment


    • #3
      Note also corrci from the Stata Journal. You can save correlation results in a separate dataset, and then do what you want with them, include list, tabulate and plot.

      Code:
      . sysuse auto, clear 
      (1978 automobile data)
       
      . corrci mpg weight displacement price, saving(corrci_results)
      
      (obs=74)
      
                                 correlations and 95% limits
      mpg          weight           -0.807   -0.874   -0.710
      mpg          displacement     -0.706   -0.804   -0.569
      mpg          price            -0.469   -0.630   -0.269
      weight       displacement      0.895    0.838    0.933
      weight       price             0.539    0.354    0.683
      displacement price             0.495    0.300    0.650
      
      . 
      . use corrci_results 
      
      
      . list if abs(r) > 0.7, noobs
      
        +-----------------------------------------------------------+
        |   var1           var2           r       lower       upper |
        |-----------------------------------------------------------|
        |    mpg         weight   -.8071749   -.8744006   -.7095432 |
        |    mpg   displacement   -.7056426   -.8044354   -.5688671 |
        | weight   displacement    .8948958    .8376901    .9326781 |
        +-----------------------------------------------------------+
      Naturally you can choose sort order, display formats, and so forth.

      Comment


      • #4
        Thanks a ton for this witty way!

        Comment


        • #5
          Thanks for the corrci tips!

          Comment

          Working...
          X