02-22-2017 08:40 AM
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?
Thanks in advance!
02-22-2017 09:32 AM
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;
cdfplot x / gamma;
If you have censored observations or some other constraint, please provide an example of your data.
02-23-2017 08:37 AM - edited 02-23-2017 08:38 AM
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;