Announcement

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

  • Spearman correlation

    Hello,

    I am trying to generate a heat plot using Speaman's correlation matrix. I know that the code needs to be different from the Pearson correlation. I also understand that the correlation matrix in this case is not in r(C) but I cannot find how to proceed.
    Can someone please help me to understand how to create this heat plot?

  • #2
    -spearman- returns its correlations in r(Rho).

    In general, to see how any command returns its results, run the command on some small demo data set, and then run -return list- to see all the returned results. Like this:
    Code:
    . sysuse auto, clear
    (1978 automobile data)
    
    . spearman price mpg headroom
    
    Number of observations = 74
    
                 |    price      mpg headroom
    -------------+---------------------------
           price |   1.0000
             mpg |  -0.5419   1.0000
        headroom |   0.0969  -0.4866   1.0000
    
    . return list
    
    scalars:
                      r(N) =  74
                    r(rho) =  -.4866017105832124
                      r(p) =  .0000147413703668
                    r(p_l) =  7.37068518342e-06
                    r(p_u) =  .9999926293148166
    
    matrices:
                   r(Nobs) :  3 x 3
                    r(Rho) :  3 x 3
                      r(P) :  3 x 3
    
    . matrix list r(Rho)
    
    symmetric r(Rho)[3,3]
                   price         mpg    headroom
       price           1
         mpg  -.54191316           1
    headroom   .09692878  -.48660171           1

    Comment


    • #3
      Thank you! It worked now!

      Comment

      Working...
      X