CORR procedure
     2013/3/6
The CORR procedure gives you
• Pearson product-moment correlation
• Rank correlation:
   • Spearman rank-order correlation
   • Kendall’s tau-b coefficient
• Hoeffding’s measure of dependence, D
• Partial correlations for Pearson, Spearman, and Kendall’s
  measurement
Syntax
         PROC CORR <options> ;
               BY variables ;
               FREQ variable ;
指定計算淨相
關時的control     ID variables ;
variable
               PARTIAL variables ;
               VAR variables ;
               WEIGHT variable ;
               WITH variables ;
         RUN; proc corr;
                 var x1 x2;
                 with y1 y2 y3;
               run;
Example 1
data example1;
do i=1 to 200;
        x=10*rannor(100);
        y=x+10*rannor(3);
        output;
end;
drop i;
;

proc corr plots=scatter spearman;
run;
Example 2 (SAS 9.2 guide)
                                              不指定var
                                                  Without control
data Fitness;
input Age Weight Oxygen RunTime @@;
datalines;
        44 89.47 44.609 11.37
        …
;
proc corr data=Fitness plots=matrix(histogram);   With control
var RunTime Weight;
partial Oxygen Age;
run;
Questions ?
Why correlation?
Pearson’s r (for linear correlation)




                                  Var X
Correlation does not “imply” causation
• Tufte:
   • "Empirically observed covariation is a necessary but not sufficient condition for
     causality."
   • "Correlation is not causation but it sure is a hint."
• If Y and X correlate significantly, then one of the following may be true:
   •   X causes Y
   •   Y causes X
   •   X and Y are consequences of a common cause other than X or Y
   •   Just coincidence
• What does “cause” mean actually?
   • It is a philosophical question

Sas corr

  • 1.
  • 2.
    The CORR proceduregives you • Pearson product-moment correlation • Rank correlation: • Spearman rank-order correlation • Kendall’s tau-b coefficient • Hoeffding’s measure of dependence, D • Partial correlations for Pearson, Spearman, and Kendall’s measurement
  • 3.
    Syntax PROC CORR <options> ; BY variables ; FREQ variable ; 指定計算淨相 關時的control ID variables ; variable PARTIAL variables ; VAR variables ; WEIGHT variable ; WITH variables ; RUN; proc corr; var x1 x2; with y1 y2 y3; run;
  • 4.
    Example 1 data example1; doi=1 to 200; x=10*rannor(100); y=x+10*rannor(3); output; end; drop i; ; proc corr plots=scatter spearman; run;
  • 5.
    Example 2 (SAS9.2 guide) 不指定var Without control data Fitness; input Age Weight Oxygen RunTime @@; datalines; 44 89.47 44.609 11.37 … ; proc corr data=Fitness plots=matrix(histogram); With control var RunTime Weight; partial Oxygen Age; run;
  • 6.
  • 7.
  • 8.
    Pearson’s r (forlinear correlation) Var X
  • 9.
    Correlation does not“imply” causation • Tufte: • "Empirically observed covariation is a necessary but not sufficient condition for causality." • "Correlation is not causation but it sure is a hint." • If Y and X correlate significantly, then one of the following may be true: • X causes Y • Y causes X • X and Y are consequences of a common cause other than X or Y • Just coincidence • What does “cause” mean actually? • It is a philosophical question