BookmarkSubscribeRSS Feed
KingRoger19
Fluorite | Level 6

Hello everybody,

I'm recoding some R code into SAS and I'm struggling with the R function qpoisbinom (ref here). This function simply takes in input a vector of quantiles and a distribution of values. This is how it is called:

p_values = qpoisbinom(p = c(0.025, 0.975), pp = Estimated_Values)

The outputs are 2 values (that should be the p_values). My Estimated_Values is a column with all my estimated values of a probability (i.e. belonging to [0,1]) 

Actually i cant find in SAS a way to replicate this code. I tried CDF function, squantile and quantile functions, PROBT and so on.

I think a good way to proceed could be to fit my values with a Poisson model and then, accordingly with quantiles 0.025 and 0.975, calculate the p-value.

I don't have the SAS IML licence so only SAS Base/STAT programming is admitted. 

I have attached the estimated values.

Thanks a lot for your help,

Gabriele

8 REPLIES 8
Ksharp
Super User

If I was right . @Rick_SAS  wrote a blog about it before .

KingRoger19
Fluorite | Level 6
Hi Ksharp, thanks for your time. Yes I found something like this https://blogs.sas.com/content/iml/2012/04/04/fitting-a-poisson-distribution-to-data-in-sas.html but when he computes the fitted density I stuck myself 'cause my list of values are in [0,1].
Ksharp
Super User
Sorry. My memory is not right . It should be Possion-Gamma distribution.
And the blog you refer to has nothing to do with your question.
Maybe @Rick_SAS would answer your question.
Rick_SAS
SAS Super FREQ

The OP says he doesn't have SAS/IML and only wants a solution that uses Base SAS and SAS/STAT. I do not know how to solve this problem without using IML. 

KingRoger19
Fluorite | Level 6

First of all, thanks for your reply Rick. This is not a good spot... Do you think it is not feasible at all or there could be a difficult way to do that? Actually I still don't want to say to the client this is undoable so I'd like to find a way. The problem is that I can not even identify the starting point...

Rick_SAS
SAS Super FREQ

I had never heard of the Poisson-binomial distribution before today and I have only skimmed the Hong (2013) paper. But I have worked with other not-so-well-known distributions such as the beta-binomial distribution. The computations for the CDF and quantiles are easier when you have access to the right set of tools.

 

Is it is feasible to solve without IML? I suppose that depends on how much you know, how good a programmer you are, and how much time you are willing to invest. You can build beautiful furniture by using hand tools, but power tools will make the job go a lot faster and easier. PROC IML provides power tools. 

 

As to a starting point, I would start from Hong's paper. He mentions several approximate methods that are feasible in SAS/STAT and the RF1 method (Eqn 9) looks tractable in the DATA step. Since your n is large, you could also use the refined normal approximation, which looks easy to implement.

 

Good luck.

SteveDenham
Jade | Level 19

Would the "refined normal approximation" method outlined in this paper https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5978503/  be applicable to your situation?  The algorithm appears relatively uncomplicated and depends on the CDF of the normal.distribution.  It would take some programming, but all of the tools are available in Base SAS.

 

SteveDenham

Rick_SAS
SAS Super FREQ

This might not help the OP, but to future SAS programmers who are searching for the Poisson-binomial distribution in SAS, I have written a few articles about it, based on the paper that the OP posted:

All the articles use PROC IML. As @SteveDenham mentions, the RNA (discussed in the third article) is your best bet for an approximation in Base SAS. You can use PROC MEANS to get the mean, std dev, and skewness of the parameters, save those values in macro variables, and then use a DATA step to compute the CDF and PDF.

 

How to get the quantile function in Base SAS is less clear. Maybe the simplest (and easiest) way is to throw out the paper and use Monte Carlo: Simulate 100,000 observations from the P-b distrib and use the empirical quantiles.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 8 replies
  • 1525 views
  • 3 likes
  • 4 in conversation