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
If I was right . @Rick_SAS wrote a blog about it before .
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.
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...
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.
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
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.
Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!
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.