## Example 39.3 Gamma Distribution Applied to Life Data

Life data are sometimes modeled with the gamma distribution. Although PROC GENMOD does not analyze censored data or provide other useful lifetime distributions such as the Weibull or lognormal, it can be used for modeling complete (uncensored) data with the gamma distribution, and it can provide a statistical test for the exponential distribution against other gamma distribution alternatives. See Lawless (2003) or Nelson (1982) for applications of the gamma distribution to life data.

The following data represent failure times of machine parts, some of which are manufactured by manufacturer A and some by manufacturer B.

```data A;
mfg = 'A';
datalines;
620  470  260  89   388  242
103  100  39   460  284  1285
218  393  106  158  152  477
403  103  69   158  818  947
399  1274 32   12   134  660
548  381  203  871  193  531
317  85   1410 250  41   1101
32   421  32   343  376  1512
1792 47   95   76   515  72
1585 253  6    860  89   1055
537  101  385  176  11   565
164  16   1267 352  160  195
1279 356  751  500  803  560
151  24   689  1119 1733 2194
763  555  14   45   776  1
;

data B;
mfg = 'B';
datalines;
1747 945  12   1453 14   150
20   41   35   69   195  89
1090 1868 294  96   618  44
142  892  1307 310  230  30
403  860  23   406  1054 1935
561  348  130  13   230  250
317  304  79   1793 536  12
9    256  201  733  510  660
122  27   273  1231 182  289
667  761  1096 43   44   87
405  998  1409 61   278  407
113  25   940  28   848  41
646  575  219  303  304  38
195  1061 174  377  388  10
246  323  198  234  39   308
55   729  813  1216 1618 539
6    1566 459  946  764  794
35   181  147  116  141  19
380  609  546
;

data lifdat;
set A B;
run;
```

The following SAS statements use PROC GENMOD to compute Type 3 statistics to test for differences between the two manufacturers in machine part life. Type 3 statistics are identical to Type 1 statistics in this case, since there is only one effect in the model. The log link function is selected to ensure that the mean is positive.

```proc genmod data = lifdat;
class mfg;
model lifetime = mfg / dist=gamma
type3;
run;
```

The output from these statements is displayed in Output 39.3.1.

Output 39.3.1 Gamma Model of Life Data
The GENMOD Procedure

Model Information
Data Set WORK.LIFDAT
Distribution Gamma

Class Level Information
Class Levels Values
mfg 2 A B

Criteria For Assessing Goodness Of Fit
Criterion DF Value Value/DF
Deviance 199 287.0591 1.4425
Scaled Deviance 199 237.5335 1.1936
Pearson Chi-Square 199 211.6870 1.0638
Scaled Pearson X2 199 175.1652 0.8802
Log Likelihood   -1432.4177
Full Log Likelihood   -1432.4177
AIC (smaller is better)   2870.8353
AICC (smaller is better)   2870.9572
BIC (smaller is better)   2880.7453

Analysis Of Maximum Likelihood Parameter Estimates
Parameter   DF Estimate Standard Error Wald 95% Confidence Limits Wald Chi-Square Pr > ChiSq
Intercept   1 6.1302 0.1043 5.9257 6.3347 3451.61 <.0001
mfg A 1 0.0199 0.1559 -0.2857 0.3255 0.02 0.8985
mfg B 0 0.0000 0.0000 0.0000 0.0000 . .
Scale   1 0.8275 0.0714 0.6987 0.9800

 Note: The scale parameter was estimated by maximum likelihood.

LR Statistics For Type 3 Analysis
Source DF Chi-Square Pr > ChiSq
mfg 1 0.02 0.8985

The -value of 0.8985 for the chi-square statistic in the Type 3 table indicates that there is no significant difference in the part life between the two manufacturers.

Using the following statements, you can refit the model without using the manufacturer as an effect. The LRCI option in the MODEL statement is specified to compute profile likelihood confidence intervals for the mean life and scale parameters.

```proc genmod data = lifdat;
model lifetime = / dist=gamma
lrci;
run;
```

Output 39.3.2 displays the results of fitting the model with the mfg effect omitted.

Output 39.3.2 Refitting of the Gamma Model: Omitting the mfg Effect
The GENMOD Procedure

Analysis Of Maximum Likelihood Parameter Estimates
Parameter DF Estimate Standard Error Likelihood Ratio 95%
Confidence Limits
Wald Chi-Square Pr > ChiSq
Intercept 1 6.1391 0.0775 5.9904 6.2956 6268.10 <.0001
Scale 1 0.8274 0.0714 0.6959 0.9762

 Note: The scale parameter was estimated by maximum likelihood.

The intercept is the estimated log mean of the fitted gamma distribution, so that the mean life of the parts is

The SCALE parameter used in PROC GENMOD is the inverse of the gamma dispersion parameter, and it is sometimes called the gamma index parameter. See the section Response Probability Distributions for the definition of the gamma probability density function. A value of 1 for the index parameter corresponds to the exponential distribution . The estimated value of the scale parameter is 0.8274. The 95% profile likelihood confidence interval for the scale parameter is (0.6959, 0.9762), which does not contain 1. The hypothesis of an exponential distribution for the data is, therefore, rejected at the 0.05 level. A confidence interval for the mean life is