0

I'm trying to reverse engineer a Stata program into SAS, and I'm having trouble with the gammap function in Stata and what it correlates to in SAS. From Stata documentation, it appears that the gammap function returns the cumulative gamma distribution.

Test Data:

PSCORE  PALPHA  PBETA
0.032352097 21.4639 0.002864125
0.030794526 21.4639 0.002864125
0.032952468 21.4639 0.002864125
0.041141297 21.4639 0.002864125
0.033376449 21.4639 0.002864125
0.032352097 5.7865  0.005516187
0.030794526 5.7865  0.005516187
0.032952468 5.7865  0.005516187
0.041141297 5.7865  0.005516187
0.033376449 5.7865  0.005516187

So in the Stata program, I have:

RESULT = gammap(PALPHA,PSCORE/PBETA)

I translated this in SAS as part of the CDF function:

RESULT = CDF('GAMMA',PALPHA,PSCORE/PBETA);

However, the results are not matching up so my theory is wrong.

Stata:

0.0045025
0.0025791
0.0055082
0.0474779
0.0063245
0.5680494
0.5214182
0.5854155
0.7804033
0.5974566

SAS:

0.99394
0.99605
0.99291
0.95694
0.99209
0.54212
0.58959
0.52384
0.29454
0.51097

Could someone offer insight on what the correct correlating SAS code might be and where I'm going wrong in using the CDF function? Should I not use the CDF function?

kstats9pt3
  • 799
  • 2
  • 8
  • 28

1 Answers1

1

The SAS CDF function takes 2 parameters for the Gamma distribution.

data have;
input PSCORE  PALPHA  PBETA;

datalines;
0.032352097 21.4639 0.002864125
0.030794526 21.4639 0.002864125
0.032952468 21.4639 0.002864125
0.041141297 21.4639 0.002864125
0.033376449 21.4639 0.002864125
0.032352097 5.7865  0.005516187
0.030794526 5.7865  0.005516187
0.032952468 5.7865  0.005516187
0.041141297 5.7865  0.005516187
0.033376449 5.7865  0.005516187
;

data want;
set have;
result = cdf('gamma',pscore,palpha,pbeta);
run;

The results in WANT seem to line up with your STATA results.

DomPazz
  • 12,415
  • 17
  • 23