Announcement

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

  • Graph - Spearman Correlation

    Hello everyone.

    I am currently looking at the correlation between two variables using the spearman correlation since I needed a non-parametric test.
    The calculations are going well, but I was unable to find out how to generate a spearman correlation graph. Can anyone help?

    Many thanks!
    . spearman A B, star(0.05)

    Number of obs = 74
    Spearman's rho = -0.6363

    Test of H0: A and B are independent
    Prob > |t| = 0.0000

  • #2
    The linked graph would plot ranks, not values. But it would be a good idea to look at both. Here's a mundane but still instructive example in which some curvature is suitably ignored by the ranks.
    Code:
    sysuse auto, clear
    
    set scheme s1color 
    egen rank1 = rank(mpg)
    egen rank2 = rank(weight)
    corr rank?
    local show : di %4.3f r(rho)
    
    scatter rank1 rank2, ms(Oh) subtitle(Spearman rank correlation `show') name(G1, replace) ytitle(Rank on mpg) xtitle(Rank on weight) aspect(1)
    
    corr mpg weight
    local show : di %4.3f r(rho)
    scatter mpg weight, ms(Oh) subtitle(Pearson correlation `show') name(G2, replace) aspect(1)
    
    graph combine G1 G2
    Click image for larger version

Name:	rankandnotrank.png
Views:	1
Size:	35.9 KB
ID:	1710444

    Comment

    Working...
    X