Sas corr
-
Upload
wensheng-chang -
Category
Documents
-
view
330 -
download
0
description
Transcript of Sas corr
CORR procedure2013/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 ;ID variables ;PARTIAL variables ;VAR variables ;WEIGHT variable ;WITH variables ;
RUN;
指定計算淨相關時的 control variable
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)
data Fitness;input Age Weight Oxygen RunTime @@;datalines;
44 89.47 44.609 11.37…
;proc corr data=Fitness plots=matrix(histogram);var RunTime Weight;partial Oxygen Age;run;
Without control
With control
不指定 var
Questions ?
Why correlation?
• Suppose 2 random variables Y and X, where Y is a variable you cannot observe directly, but X is the variable you can observe directly.• If Y and X are dependent in a certain relationship f(X), then we can
observe Y through X by the relationship
• e.g. Y ~ Happiness, X ~ Smiling
Pearson’s r (for linear correlation)
• How many variance of Y can be explained by X
Var Y
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