/***************************************************************************************************************** SAS file name: Gamma_Curves.sas File location: _________________________________________________________________________________________________________________ Purpose: Describe the Gamma distribution and draw Probability Density function and Cumulative Density Function for different values of the parameters. Author: Peter Clemmensen Creation 04/03/2017 This program supports the Gamma Distribution examples on SASnrd.com *****************************************************************************************************************/ /* Create Gamma PDF data */ data Gamma_PDF; do x=0 to 300 by 1; pdf1=pdf('Gamma', x, 0.5, 60); pdf2=pdf('Gamma', x, 1, 60); pdf3=pdf('Gamma', x, 2, 60); pdf4=pdf('Gamma', x, 3, 60); output; end; run; /* Draw PDF plots */; ods graphics on / outputfmt=png; ****ods pdf file='/home/mstear0/Eosinophil/Eosinophildist.pdf' dpi=600; ods pdf file='Gammadist.pdf' dpi=600; title "Gamma Densities"; title2 "For different values of scale and shape parameters"; proc sgplot data = Gamma_PDF noautolegend; series x=x y=pdf1 / lineattrs=(thickness=2) legendlabel="shape = 0.5 scale = 60"; series x=x y=pdf2 / lineattrs=(thickness=2) legendlabel="shape = 1 scale = 60"; series x=x y=pdf3 / lineattrs=(thickness=2) legendlabel="shape = 2 scale = 60"; series x=x y=pdf4 / lineattrs=(thickness=2) legendlabel="shape = 3 scale = 60"; keylegend / position=NE location=inside across=1 noborder valueattrs=(Size=12 Weight=Bold); yaxis min=0 max=0.02 label="PROBABILITY DENSITY FUNCTION" labelattrs=(size=14 weight=Bold); xaxis min=0 max=300 label='VALUE' labelattrs=(size=14 weight=Bold); run; title; proc univariate data=Gamma_PDF; var pdf1; histogram pdf1 / gamma lognormal; run; /* Create Gamma CDF data */ /* data Gamma_PDF; do x=0 to 10 by 0.01; cdf1=cdf('Gamma', x, 1, 2); cdf2=cdf('Gamma', x, 9, .5); cdf3=cdf('Gamma', x, 2, 2); output; end; run; /* Draw PDF plots */ /* title "Gamma Cummulative Density Functions"; title2 "For Different Values of (*ESC*){unicode lambda} and a"; proc sgplot data = Gamma_PDF noautolegend; series x=x y=cdf1 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode lambda} = 2 a = 1"; series x=x y=cdf2 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode lambda} = 0.5 a = 9"; series x=x y=cdf3 / lineattrs=(thickness=3) legendlabel="(*ESC*){unicode lambda} = 2 a = 2"; keylegend / position=NW location=inside across=1 noborder valueattrs=(Size=12 Weight=Bold); yaxis min=0 max=1 label="CDF" labelattrs=(size=12 weight=Bold); xaxis min=0 max=10 label='x' labelattrs=(size=12 weight=Bold); run; title; */ /* %let a=2; %let lambda=2; data PDF; do x=0 to 15 by 0.01; pdf=pdf('Gamma', x, &a, &lambda); output; end; run; title "Gamma Probability Densities."; title2 "For Different Values of a=&a and (*ESC*){unicode lambda}=&lambda."; proc sgplot data = PDF noautolegend; series x=x y=pdf/ lineattrs=(thickness=3) legendlabel="a = 1 (*ESC*){unicode lambda} = 3"; yaxis label="PDF" labelattrs=(size=12 weight=Bold); xaxis label='x' labelattrs=(size=12 weight=Bold); run; title; */