/***************************************************** SAS FILE THAT GENERATES ROBUSTNESS OF FLAT-PCURVE UNDER NULL TO NONNORMALITY, SUPPLEMENT 2 Simonsohn, Nelson, Simmons (JEP:G 2013) "p-curve: a key to the file-drawer"; Figure S1 in Supplement 2 plots p-curves obtained from t-tests performed on identically distributed variables that are not normally distributed. • The code begins generating an empty dataset with user set &simtot rows (typically 100k) • It then generates one column per per-sample observation, so if user set n=20 it generates 20 columns representing 20 observations in sample one, and then another 20 for the other sample. • The distribution the values of those observations followed is determined by the user via f1 and f2 in the macro. E.g., to simulate normally distributed variables user sets f1=normal(-1) • Program then computes means and SDs for each simulated study and performs a t-test. • It then tabulates the frequency of p-values in each bin for the &simtot simulations; Code written by Uri Simonsohn This version: 2013 04 16 ***************************************************** */ %macro difm(simtot,n,f1,f2,mk); *(1) Generate empty file with simtot rows; data p&mk; do i=1 to &simtot; output; end; run; *(2) &n random variables for each of two cells; data p&mk; set p&mk; array y1(&n) y1_1 - y1_&n; array y2(&n) y2_1 - y2_&n; do k=1 to &n; y1(k)=&f1; y2(k)=&f2; end; av1=mean(of y1_1-y1_&n); av2=mean(of y2_1-y2_&n); sd1=std(of y1_1-y1_&n); sd2=std(of y2_1-y2_&n); se=(sd1**2/&n +sd2**2/&n)**.5; t=(av1-av2)/se; p=2*(1-cdf("t",abs(t),2*(&n)-2)); p01=ceil(p*100)/100; run; title simtot ||| f1= &f1 ||| f2= &f2; proc freq; table p01; where p<.05; run; %mend; %mclear; *Normal; %difm(simtot=500000,n=15,f1=normal(1875),f2=normal(1125),mk=1); *Uniform continuous; %difm(simtot=500000,n=15,f1=uniform(875),f2=uniform(125),mk=2); *Uniform discrete; %difm(simtot=500000,n=15,f1=round(uniform(2001),.25),f2=round(uniform(2001),.25),mk=3); *Poisson skewed (k=4); %difm(simtot=500000,n=15,f1=max(min(rand('poisson',2),4),1),f2=max(min(rand('poisson',2),4),1),mk=4);