-
-
Save MJacobs1985/efd8ae0a2d3ea9b00928acff54b68e5c to your computer and use it in GitHub Desktop.
Simulations in SAS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* PROC IML --> using different degrees of freedom */ | |
ods graphics on / outputfmt=svg; | |
proc iml; | |
call randseed(1234); /* set random number seed */ | |
n = j(100,1); | |
t2 = j(100,1); | |
t4 = j(100,1); | |
t8 = j(100,1); | |
t16 = j(100,1); | |
t32 = j(100,1); | |
t64 = j(100,1); | |
call randgen(n, 'normal'); | |
call randgen(t2, 't',1); | |
call randgen(t4, 't',3); | |
call randgen(t8, 't',7); | |
call randgen(t16, 't',15); | |
call randgen(t32, 't',31); | |
call randgen(t64, 't',63); | |
create MyData var {n t2 t4 t8 t16 t32 t64}; /** create data set from vectors seperate vectors **/ | |
append; | |
close MyData; /** close the data set **/ | |
quit; | |
proc sgplot data=MyData; | |
density n / legendlabel='Normal' lineattrs=(color=black pattern=1); | |
*density t2 / legendlabel='T (df=1)' lineattrs=(color=red pattern=1); | |
*density t4 / legendlabel='T (df=3)' lineattrs=(color=pink pattern=1); | |
density t8 / legendlabel='T (df=7)' lineattrs=(color=green pattern=1); | |
density t16 / legendlabel='T (df=15)' lineattrs=(color=blue pattern=1); | |
density t32 / legendlabel='T (df=31)' lineattrs=(color=orange pattern=1); | |
density t64 / legendlabel='T (df=63)' lineattrs=(color=red pattern=1); | |
xaxis min=-7 max=7; | |
run; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment