Contributor
Posts: 24

# Incomplete gamma function

Good afternoon,

I need to calculate the incomplete gamma function for a sample size calculation regarding advanced survival analysis with correlated frailties. Do you have any hint, how I can calculate the incomplete gamma function in SAS?

SAS Super FREQ
Posts: 3,839

## Re: Incomplete gamma function

Applied mathematicians and physicists call the function an "incomplete gamma function," but a statistician calls it the CDF of the gamma distribution.  For the definition, see the doc for the CDF function. (For an explanation of the ideas, see this article on the incomplete beta function.)

If you are asking for a plot of the empirical distribution of the data overlaid with a gamma CDF, you can use PROC UNIVARIATE:

proc univariate data=have;

var  x;

cdfplot x / gamma;

run;

If you have censored observations or some other constraint, please provide an example of your data.

Super Contributor
Posts: 301

## Re: Incomplete gamma function

[ Edited ]

You can just use the product: cdf('gamma',x,alpha)*gamma(alpha),

where alpha is the shape parameter and x is the value you want to evaluate the incomplete gammafunction in.

That product gives the same value as the integral that define the incomplete gammafunction:

``````data _null_;
alpha=2;

delta=2**(-20);
integral=0;
do t=delta to 3 by delta;
integral+t**(alpha-1)*exp(-t)*delta;
end;

y=cdf('gamma',3,alpha)*gamma(alpha);
put y=  / integral=;
ruN;``````

Discussion stats
• 2 replies
• 305 views
• 0 likes
• 3 in conversation