Programming the statistical procedures from SAS

Fitting poisson distribution to a histogram

Accepted Solution Solved
Reply
Contributor
Posts: 24
Accepted Solution

Fitting poisson distribution to a histogram

I want to chart the poisson distribution on a histogram and subsequently to a qqplot. Proc univariate doesn't seem to support this. Any help is deeply appreciated.


Accepted Solutions
Solution
‎04-02-2012 09:39 AM
SAS Super FREQ
Posts: 3,547

Fitting poisson distribution to a histogram

1) Estimate the parameter with PROC GENMOD: http://support.sas.com/kb/24/166.html

2) Use the DATA step and he tPDF function to compute the Poisson PDF (well, really the PMF=probability mass function) for the range of x values of interest.

3) The Poisson is a discrete distribution, so your data should be plotted with a bar chart. Because PROC SGPLOT doesn't enable you to overlay a bar chart and a scatter plot of (x, pdf(x)), you need to use the GTL to overlay the two plots.

4) You can create a Q-Q plot by following the steps laid out in my blog: http://blogs.sas.com/content/iml/2011/10/28/modeling-the-distribution-of-data-create-a-qq-plot/

Rick

View solution in original post


All Replies
Respected Advisor
Posts: 2,655

Fitting poisson distribution to a histogram

Do you have access to SAS/QC?  If so, PROC CAPABILITY should be able to help with this problem.

Steve Denham

Contributor
Posts: 24

Re: Fitting poisson distribution to a histogram

Unfortunately I don't have access to SAS/QC.

SAS Super FREQ
Posts: 3,547

Re: Fitting poisson distribution to a histogram

CAPABILITY and UNIVARIATE only model continuous distributions. The Poisson distribution is discrete.

Respected Advisor
Posts: 2,655

Re: Fitting poisson distribution to a histogram

I apologize--I gave an answer without checking the documentation.  I knew CAPABILITY had several distributions, and wrongly assumed that it included the Poisson.  There is nothing that is better than reading the manual, and I missed it on this one.

Steve Denham

Solution
‎04-02-2012 09:39 AM
SAS Super FREQ
Posts: 3,547

Fitting poisson distribution to a histogram

1) Estimate the parameter with PROC GENMOD: http://support.sas.com/kb/24/166.html

2) Use the DATA step and he tPDF function to compute the Poisson PDF (well, really the PMF=probability mass function) for the range of x values of interest.

3) The Poisson is a discrete distribution, so your data should be plotted with a bar chart. Because PROC SGPLOT doesn't enable you to overlay a bar chart and a scatter plot of (x, pdf(x)), you need to use the GTL to overlay the two plots.

4) You can create a Q-Q plot by following the steps laid out in my blog: http://blogs.sas.com/content/iml/2011/10/28/modeling-the-distribution-of-data-create-a-qq-plot/

Rick

Respected Advisor
Posts: 4,750

Fitting poisson distribution to a histogram

Great advice! There is even an easier way to do step 3 now. The VBARPARM can be combined with SERIES plots in SGPLOT (I think this is new to 9.3).

PG

PG
SAS Super FREQ
Posts: 3,547

Fitting poisson distribution to a histogram

Clever! Yes, you can use PROC FREQ to tabulate the data. You'll want to scale the PERCENT variable to a proportion so that it is on the same scale as the PDF.

Contributor
Posts: 24

Re: Fitting poisson distribution to a histogram

Rick,

Thank you so much for the response and then subsequently backing this with your blog. I have read and shared your blogs in the past and they have always worked.

Thanks,

Jatin

SAS Super FREQ
Posts: 3,547

Re: Fitting poisson distribution to a histogram

You are welcome. And thanks to you for the interesting idea.

For those who do not read my blog, I followed up my first post with a second: The Poissonness plot: A goodness-of-fit diagnostic

in which I present a graphical diagnostic plot that is an alternative to using a Q-Q plots.

SAS Super FREQ
Posts: 3,547

Fitting poisson distribution to a histogram

I explain the details of my answer and give an example (which includes PGStats's suggestion) on my blog in the article "Fitting a Poisson Distribution to Data in SAS."

The same approach should work for other discrete distributions such as negative binomial and geometric distributions.

Rick

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 10 replies
  • 4932 views
  • 4 likes
  • 4 in conversation