BookmarkSubscribeRSS Feed
Abdelkarim
Calcite | Level 5
I am interested in beta binomial distribution. It is not included in SAS call functions and also CDF and inverse CDF. I have the following concerns about these functions: 1.How CDF of beta binomial distribution can be calculated in SAS (the steps or module are needed to have this function) such that when substitute n, x, eta1, and eta2, it gives the CDF value (“p”)? 2.How the inverse CDF of beta binomial distribution can be calculated in SAS (the steps are needed to have this function) such that when substitute n, eta1, eta2, and “p” it gives the inverse CDF value the (quantile)? Thank you
2 REPLIES 2
Rick_SAS
SAS Super FREQ

You are correct that there is not a built-in function for the CDF and quantile of the beta-binomial distribution. If you have SAS/IML, use that to implement the PDF, CDF, and quantile functions. You could compute the CDF with the DATA step, but it will be easier in SAS/IML. The quantile computation is unwieldy in Base SAS. 

 

This is a non-trivial task, so I assume you are proficient in both statistics and programming. The basic approach is this:

  1. Review the concepts behind the four essential functions for probability distributions. For a worked out example of a continuous distribution, see the article on the folded normal distribution.  However, the beta-binomial is a DISCRETE probability distribution, so the integrals are replaced by sums.
  2. Use the formulas on the Wikipedia page on the beta-binomial distribution to implement the PDF function. (Actually, computing the logPDF and then exponentiating is more stable numerically.)
  3. The CDF function is the cumulative sum of the PDF. That is, CDF(x) = sum( PDF(0:x) ).
  4. The quantile function for a discrete distribution is not one to one. Thus the "inverse CDF" is not well defined. Instead, recall that "for discrete distributions, the quantile is the smallest value for which the CDF is greater than or equal to the given probability."  Therefore you can compute the CDF function and then for any p use the LOC function to find the smallest value of x for which p <= CDF(x).

 

Study the articles that I have linked to and give it a try. If you get stuck, write back and include the code you have written.

Rick_SAS
SAS Super FREQ

I have recently written a blog post that shows how to compute essential parts of the beta-binomial distribution.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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
  • 2 replies
  • 3136 views
  • 2 likes
  • 2 in conversation