A New View of Statistics

© 1997 Will G Hopkins

Go to: Previous · Contents · Search · Home


SAS Programs for A SCALE OF MAGNITUDES FOR EFFECT STATISTICS

options linesize=100;
options pagesize=30;
 
/*
What's the correlation corresponding to an effect size?
Results: 
ES: 0.2  0.63  1.16  1.96  4.10
 r: 0.1  0.3   0.5   0.7   0.9
 
Also, what is the freq difference when you dichotomize 
a normally distributed outcome "through the middle" 
of an effect-size difference?
Results:
Comes close to the scale: 8  24  44  67  96 
              instead of 10  30  50  70  90
*/
*generate es diff;
%macro data;
data dat1;
do id=1 to &samplen/2;
  x=1;
  y=rannor(0);
  if y>&es/2 then outcome="positive"; else outcome="negative";
  output;
  end;
do id=1 to &samplen/2;
  x=2;
  y=rannor(0)+&es;
  if y>&es/2 then outcome="positive"; else outcome="negative";
  output;
  end;
drop id;
 
%mend;
%let es=1.96;
%let samplen=100000;
%data;
 
proc corr;
var y x;
 
proc freq;
tables outcome*x/norow;
 
run;
 
 
/*
Divides a scattergram into four regions and calculates 
freqs and effect sizes for those regions.
Results:
correlation:  0.1   0.3  0.5  0.7  0.9
  freq diff:   7    20   33   50   70
effect size:  0.17  0.50 0.87 1.35 2.06
*/
*generate correlated y and x;
%macro data;
data dat1;
do id=1 to &samplen;
  x=rannor(0);
  if x<0 then group="cont"; else group="case";
  y=&r*x+sqrt(1-&r**2)*rannor(0);
  if y<0 then outcome="positive"; else outcome="negative";
  output;
  end;
drop id;
 
%mend;
%let r=0.1; *correlation between x and y;
%let samplen=100000;
%data;
 
proc corr;
var y x;
 
proc freq;
tables outcome*group/norow;
 
proc sort;
by group;
 
proc means n mean std maxdec=3;
var y;
by group;
 
run;
 
proc univariate plot;
var y;
by group;
run;
 
 
 
 
 
/*
What is the effect size corresponding to a freq diff 
between two groups?
There's a more elegant way of doing this, I know!
*/
%macro data;
data;
x=1; y=1; do i=1 to &n*&f/100; output; end;
x=1; y=0; do i=1 to &n-&n*&f/100; output; end;
x=2; y=1; do i=1 to &n*(&f+&deltaf)/100; output; end;
x=2; y=0; do i=1 to &n-&n*(&f+&deltaf)/100; output; end;
%mend;
 
%let n=1000;
%let f=35;
%let deltaf=30;
%data;
 
proc means n mean std;
var y;
by x;
 
run;
 
 
/*
What is the validity correlation when you dichotomize 
a normally distributed variable?
This addresses the question of loss of info when dichotomize.
Answer: r=0.8!
*/
%macro data;
data dat1;
do id=1 to &samplen;
  x=rannor(0);
  if x<0 then y=-1; else y=1;
  output;
  end;
drop id;
 
%mend;
%let samplen=10000;
%data;
 
proc corr;
var y x;
 
run;
 
 
/*
What is the average separation of two people drawn at random 
from a normal distribution?;
Answer: effect size of 1.13.
*/
%macro data;
data dat1;
do id=1 to &samplen;
  x1=rannor(0);
  x2=rannor(0);
  diff=abs(x1-x2);
  output;
  end;
drop id;
 
%mend;
%let samplen=10000;
%data;
 
proc univariate plot;
var diff;
 
run;


Go to: Previous · Contents · Search · Home
resources=AT=sportsci.org · webmaster=AT=sportsci.org · Sportsci Homepage · Copyright ©1997
Last updated 10 June 97