/***************************************************************************************************************** SAS file name: Neg_Binomial_Curves.sas File location: _________________________________________________________________________________________________________________ Purpose: To draw densities for three different negative binomial distributions Author: Peter Clemmensen Creation Date: 12/06/2017 This Program supports the Example page "Negative Binomial Distribution" on SASnrd.com *****************************************************************************************************************/ /* Negative Binomial Probability Mass Function Data, holding p fixed */ data negbin_PMF_n; do n=0, 2, 5; do k=0 to 10; pmf=pdf('negbinomial', n, 0.5, k); output; end; end; run; /* Draw PMF Curves */ title "Negative Binomial Probability Mass Function"; title2 "For Different Values of n, fixing p=0.5"; proc sgplot data=negbin_PMF_n noautolegend; series x=k y=pmf / markers group=n lineattrs=(thickness=2) markerattrs=(size=10 symbol=circlefilled); xaxis values=(1 to 10) label='k' labelattrs=(size=12 weight=Bold); yaxis display=(nolabel); keylegend / title="n =" titleattrs=(Size=12 Weight=Bold) position=NE location=inside across=1 noborder valueattrs=(Size=12 Weight=Bold); run; title; /* Negative Binomial Probability Mass Function Data, holding n fixed */ data negbin_PMF_p; do p=0.25, 0.5, 0.75; do k=1 to 10; pmf=pdf('negbinomial', 5 , p, k); output; end; end; run; /* Draw PMF Curves */ title "Negative Binomial Probability Mass Function"; title2 "For Different Values of p, fixing n=10"; proc sgplot data=negbin_PMF_p noautolegend; series x=k y=pmf / markers group=p lineattrs=(thickness=2) markerattrs=(size=10 symbol=circlefilled); xaxis values=(1 to 10) label='k' labelattrs=(size=12 weight=Bold); yaxis display=(nolabel) values=(0 to 0.15 by 0.05); keylegend / title="p =" titleattrs=(Size=12 Weight=Bold) position=NW location=inside across=1 noborder valueattrs=(Size=12 Weight=Bold); run; title;