DATA Step, Macro, Functions and more

Function to Return Poisson Parameter

Reply
Frequent Contributor
Posts: 80

Function to Return Poisson Parameter

Hello!

The functions POISSON(λ,x) and CDF('POISSON',x,λ) return the value of P(X > x | X ~ Poisson(λ)) given the value of the parameter, λ, and the observed count, x, are input.

I would like to do somewhat the opposite: given a probability, p, and an observed count, x, is there a function that will return the value of λ?

Thanks.
Valued Guide
Posts: 2,177

Re: Function to Return Poisson Parameter

have you looked at CALL RANPOI()
Frequent Contributor
Posts: 80

Re: Function to Return Poisson Parameter

Thanks for the tip Peter C. However, when I looked at the call, it returns random numbers from a Poisson distribution. I am looking for something to return the parameter of a Poisson distribution that matches certain criteria.
Valued Guide
Posts: 634

Re: Function to Return Poisson Parameter

I think you may be looking for the QUANTILE function.
[pre]
data a;
m=1;
n=2;
x = poisson(m,n);
y=quantile('POISSON',x,m);
put x= y=;
run;
[/pre]

There used to be a series of probability and inverse prob functions. Although some are still documented most have been supplanted by the more powerful PDF, CDF, and QUANTILE functions.
Respected Advisor
Posts: 2,655

Re: Function to Return Poisson Parameter

This still returns the x value in the OP. I believe he is looking to return lambda (or m in this example).

The problem is that m is the solution for a cumulative sum of the following type:

probability = sum (i from 0 to n) {exp (-m) * (m**i) / i!}

I can only guess that some sort of grid search/optimization scenario would be able to do this on a general basis.

SteveDenham
Frequent Contributor
Posts: 80

Re: Function to Return Poisson Parameter

Posted in reply to SteveDenham
Yes, Steve, this is what I was hoping for. I thought maybe SAS had a numerical algorithm already in place to find this. I guess I can write a macro though.

Thanks!
SAS Super FREQ
Posts: 3,755

Re: Function to Return Poisson Parameter

This is a root-finding problem. Define

f(lambda) = target - cdf("poisson", n, lambda);

and solve for the zeros of f. This is always possible (and has a unique solution) because the CDF is an increasing function of lambda. (Of course, 0<target<1).

To solve the problem, find a root-finding algorithm such as the bisection method implemented in SAS. (I believe that the %inv macro at

http://ftp.sas.com/samples/A57496 gives you what you need; Although it is written as a macro, you ought to be able to decipher it.)

If you have SAS/IML, see

http://support.sas.com/documentation/cdl/en/imlug/63541/HTML/default/viewer.htm#imlug_genstatexpls_s...

Ask a Question
Discussion stats
  • 6 replies
  • 269 views
  • 0 likes
  • 5 in conversation