The NLMIXED Procedure

Example 83.5 Failure Time and Frailty Model

(View the complete code for this example.)

In this example an accelerated failure time model with proportional hazard is fitted with and without random effects. The data are from the "Getting Started" example of PROC LIFEREG; see Chapter 70: The LIFEREG Procedure. Thirty-eight patients are divided into two groups of equal size, and different pain relievers are assigned to each group. The outcome reported is the time in minutes until headache relief. The variable censor indicates whether relief was observed during the course of the observation period (censor = 0) or whether the observation is censored (censor = 1). The SAS DATA step for these data is as follows:

data headache;
   input minutes group censor @@;
   patient = _n_;
   datalines;
11  1  0    12  1  0    19  1  0    19  1  0
19  1  0    19  1  0    21  1  0    20  1  0
21  1  0    21  1  0    20  1  0    21  1  0
20  1  0    21  1  0    25  1  0    27  1  0
30  1  0    21  1  1    24  1  1    14  2  0
16  2  0    16  2  0    21  2  0    21  2  0
23  2  0    23  2  0    23  2  0    23  2  0
25  2  1    23  2  0    24  2  0    24  2  0
26  2  1    32  2  1    30  2  1    30  2  0
32  2  1    20  2  1
;

In modeling survival data, censoring of observations must be taken into account carefully. In this example, only right censoring occurs. If , , and denote the density of failure, the hazard function, and the survival distribution function at time t, respectively, then the log likelihood can be written as

(See Cox and Oakes 1984, Ch. 3.) In these expressions is the set of uncensored observations, is the set of censored observations, and n denotes the total sample size.

The proportional hazards specification expresses the hazard in terms of a baseline hazard, multiplied by a constant. In this example the hazard is that of a Weibull model and is parameterized as and .

The linear predictor is set equal to the intercept in the reference group (group = 2); this defines the baseline hazard. The corresponding distribution of survival past time t is . See Cox and Oakes (1984, Table 2.1) and the section "Supported Distributions" in Chapter 70: The LIFEREG Procedure, for this and other survival distribution models and various parameterizations.

The following NLMIXED statements fit this accelerated failure time model and estimate the cumulative distribution function of time to headache relief:

proc nlmixed data=headache;
   bounds gamma > 0;
   linp  = b0 - b1*(group-2);
   alpha = exp(-linp);
   G_t   = exp(-(alpha*minutes)**gamma);
   g     = gamma*alpha*((alpha*minutes)**(gamma-1))*G_t;
   ll    = (censor=0)*log(g) + (censor=1)*log(G_t);
   model minutes ~ general(ll);
   predict 1-G_t out=cdf;
run;

Output 83.5.1: Specifications Table for Fixed-Effects Failure Time Model

The NLMIXED Procedure

Specifications
Data SetWORK.HEADACHE
Dependent Variableminutes
Distribution for Dependent VariableGeneral
Optimization TechniqueDual Quasi-Newton
Integration MethodNone


The "Specifications" table shows that no integration is required, since the model does not contain random effects (Output 83.5.1).

Output 83.5.2: Negative Log Likelihood with Default Starting Values

Initial Parameters
gammab0b1Negative
Log
Likelihood
111263.990327


No starting values were given for the three parameters. The NLMIXED procedure assigns the default value of 1.0 in this case. The negative log likelihood based on these starting values is shown in Output 83.5.2.

Output 83.5.3: Iteration History for Fixed-Effects Failure Time Model

Iteration History
IterationCallsNegative
Log
Likelihood
DifferenceMaximum
Gradient
Slope
14169.244394.7460222.5599-2230.83
28142.873526.370814.8863-3.64643
311140.63372.23981411.2523-9.49454
415122.890717.7430419.4496-2.50807
517121.39701.49369913.8558-4.55427
620120.62380.77311613.6706-1.38064
722119.27821.34564715.7801-1.69072
826116.27133.00687126.9403-3.25290
930109.42746.84392519.8838-6.92890
1035103.29816.12929812.1565-4.96054
1140101.68621.61186314.2487-4.34059
1242100.02791.65836411.6985-13.2049
134699.91890480.1089713.60255-0.55176
144999.87388360.0450210.17071-0.16645
155299.87363920.0002440.050822-0.00041
165599.87363514.071E-60.000705-6.9E-6
175899.87363516.1E-104.768E-6-1.23E-9

NOTE: GCONV convergence criterion satisfied.


The "Iteration History" table shows that the procedure converges after 17 iterations and 34 evaluations of the objective function (Output 83.5.3).

Output 83.5.4: Fit Statistics and Parameter Estimates

Fit Statistics
-2 Log Likelihood199.7
AIC (smaller is better)205.7
AICC (smaller is better)206.5
BIC (smaller is better)210.7

Parameter Estimates
ParameterEstimateStandard
Error
DFt ValuePr > |t|95% Confidence LimitsGradient
gamma4.71280.6742386.99<.00013.34796.07775.327E-8
b03.30910.058853856.23<.00013.19003.4283-4.77E-6
b1-0.19330.0785638-2.460.0185-0.3523-0.03426-1.22E-6


The parameter estimates and their standard errors shown in Output 83.5.4 are identical to those obtained with the LIFEREG procedure and the following statements:

proc lifereg data=headache;
   class group;
   model minutes*censor(1) = group / dist=weibull;
   output out=new cdf=prob;
run;

The t statistic and confidence limits are based on 38 degrees of freedom. The LIFEREG procedure computes z intervals for the parameter estimates.

For the two groups you obtain

The probabilities of headache relief by t minutes are estimated as

These probabilities, calculated at the observed times, are shown for the two groups in Output 83.5.5 and printed with the following statements:

proc print data=cdf;
   var group censor patient minutes pred;
run;

Since the slope estimate is negative with p-value of 0.0185, you can infer that pain reliever 1 leads to overall significantly faster relief, but the estimated probabilities give no information about patient-to-patient variation within and between groups. For example, while pain reliever 1 provides faster relief overall, some patients in group 2 might respond more quickly than some patients in group 1. A frailty model enables you to accommodate and estimate patient-to-patient variation in health status by introducing random effects into a subject’s hazard function.

Output 83.5.5: Estimated Cumulative Distribution Function

ObsgroupcensorpatientminutesPred
1101110.03336
2102120.04985
3103190.35975
4104190.35975
5105190.35975
6106190.35975
7107210.51063
8108200.43325
9109210.51063
101010210.51063
111011200.43325
121012210.51063
131013200.43325
141014210.51063
151015250.80315
161016270.90328
171017300.97846
181118210.51063
191119240.73838
202020140.04163
212021160.07667
222022160.07667
232023210.24976
242024210.24976
252025230.35674
262026230.35674
272027230.35674
282028230.35674
292129250.47982
302030230.35674
312031240.41678
322032240.41678
332133260.54446
342134320.87656
352135300.78633
362036300.78633
372137320.87656
382138200.20414


The following statements model the hazard for patient i in terms of , where is a (normal) random patient effect. Notice that the only difference from the previous NLMIXED statements are the RANDOM statement and the addition of z in the linear predictor. The empirical Bayes estimates of the random effect (RANDOM statement), the parameter estimates (ODS OUTPUT statement), and the estimated cumulative distribution function (PREDICT statement) are saved to subsequently graph the patient-specific distribution functions.

ods output ParameterEstimates=est;
proc nlmixed data=headache;
   bounds gamma > 0;
   linp  = b0 - b1*(group-2) + z;
   alpha = exp(-linp);
   G_t   = exp(-(alpha*minutes)**gamma);
   g     = gamma*alpha*((alpha*minutes)**(gamma-1))*G_t;
   ll = (censor=0)*log(g) + (censor=1)*log(G_t);
   model minutes ~ general(ll);
   random z ~ normal(0,exp(2*logsig)) subject=patient out=EB;
   predict 1-G_t out=cdf;
run;

Output 83.5.6: Specifications for Random Frailty Model

The NLMIXED Procedure

Specifications
Data SetWORK.HEADACHE
Dependent Variableminutes
Distribution for Dependent VariableGeneral
Random Effectsz
Distribution for Random EffectsNormal
Subject Variablepatient
Optimization TechniqueDual Quasi-Newton
Integration MethodAdaptive Gaussian Quadrature


The "Specifications" table shows that the objective function is computed by adaptive Gaussian quadrature because of the presence of random effects (compare Output 83.5.6 and Output 83.5.1). The "Dimensions" table reports that nine quadrature points are being used to integrate over the random effects (Output 83.5.7).

Output 83.5.7: Dimensions Table for Random Frailty Model

Dimensions
Observations Used38
Observations Not Used0
Total Observations38
Subjects38
Max Obs per Subject1
Parameters4
Quadrature Points9


Output 83.5.8: Iteration History for Random Frailty Model

Iteration History
IterationCallsNegative
Log
Likelihood
DifferenceMaximum
Gradient
Slope
19142.121428.8222512.1448-88.8664
212136.44045.68104225.9310-65.7217
316122.972013.4683346.5655-146.887
419120.90482.06721623.7794-94.2862
523109.224111.6806857.6549-92.4075
626105.06474.1594114.82465-19.5879
728101.90223.16252614.1287-6.33767
83199.69073952.2114687.67682-3.42364
93499.36540330.3253365.68920-0.93978
103799.26021780.1051850.31764-0.23408
114099.25443400.0057841.17351-0.00556
124299.24569730.0087370.24741-0.00871
134599.24454450.0011530.10494-0.00218
144899.24449580.0000490.005646-0.00010
155199.24449579.147E-80.000271-1.84E-7

NOTE: GCONV convergence criterion satisfied.


The procedure converges after 15 iterations (Output 83.5.8). The achieved –2 log likelihood is only 1.2 less than that in the model without random effects (compare Output 83.5.9 and Output 83.5.4). Compared to a chi-square distribution with one degree of freedom, the addition of the random effect appears not to improve the model significantly. You must exercise care, however, in interpreting likelihood ratio tests when the value under the null hypothesis falls on the boundary of the parameter space (see, for example, Self and Liang 1987).

Output 83.5.9: Fit Statistics for Random Frailty Model

Fit Statistics
-2 Log Likelihood198.5
AIC (smaller is better)206.5
AICC (smaller is better)207.7
BIC (smaller is better)213.0


Output 83.5.10: Parameter Estimates

Parameter Estimates
ParameterEstimateStandard
Error
DFt ValuePr > |t|95% Confidence LimitsGradient
gamma6.28672.1334372.950.00551.964010.6093-1.89E-7
b03.27860.065763749.86<.00013.14533.41180.000271
b1-0.17610.0826437-2.130.0398-0.3436-0.008670.000111
logsig-1.90270.527337-3.610.0009-2.9710-0.83430.000027


The estimate of the Weibull parameter has changed drastically from the model without random effects (compare Output 83.5.10 and Output 83.5.4). The variance of the patient random effect is . The listing in Output 83.5.11 shows the empirical Bayes estimates of the random effects. These are the adjustments made to the linear predictor in order to obtain a patient’s survival distribution. The listing is produced with the following statements:

proc print data=eb;
   var Patient Effect Estimate StdErrPred;
run;

Output 83.5.11: Empirical Bayes Estimates of Random Effects

ObspatientEffectEstimateStdErrPred
11z-0.135970.23249
22z-0.133230.22793
33z-0.062940.13813
44z-0.062940.13813
55z-0.062940.13813
66z-0.062940.13813
77z-0.025680.11759
88z-0.044990.12618
99z-0.025680.11759
1010z-0.025680.11759
1111z-0.044990.12618
1212z-0.025680.11759
1313z-0.044990.12618
1414z-0.025680.11759
1515z0.059800.11618
1616z0.104580.12684
1717z0.171470.14550
1818z0.064710.13807
1919z0.111570.14604
2020z-0.134060.22899
2121z-0.126980.21666
2222z-0.126980.21666
2323z-0.085060.15701
2424z-0.085060.15701
2525z-0.057970.13294
2626z-0.057970.13294
2727z-0.057970.13294
2828z-0.057970.13294
2929z0.064200.13956
3030z-0.057970.13294
3131z-0.042660.12390
3232z-0.042660.12390
3333z0.076180.14132
3434z0.162920.16459
3535z0.131930.15528
3636z0.063270.12124
3737z0.162920.16459
3838z0.020740.14160


The predicted values and patient-specific survival distributions can be plotted with the SAS code that follows:

proc transpose data=est(keep=estimate)
    out=trest(rename=(col1=gamma col2=b0 col3=b1));
run;

data pred;
   merge eb(keep=estimate) headache(keep=patient group);
   array pp{2} pred1-pred2;
   if _n_ = 1 then set trest(keep=gamma b0 b1);
   do time=11 to 32;
      linp      = b0 - b1*(group-2) + estimate;
      pp{group} = 1-exp(- (exp(-linp)*time)**gamma);
      symbolid  = patient+1;
      output;
   end;
   keep pred1 pred2 time patient;
run;

data pred;
   merge pred
         cdf(where  = (group=1)
             rename = (pred=pcdf1 minutes=minutes1)
             keep   = pred minutes group)
         cdf(where  = (group=2)
             rename = (pred=pcdf2 minutes=minutes2)
             keep   = pred minutes group);
   drop group;
run;

proc sgplot data=pred noautolegend;
   label minutes1='Minutes to Headache Relief'
         pcdf1   ='Estimated Patient-specific CDF';
   series  x=time     y=pred1  /
           group=patient
           lineattrs=(pattern=solid color=black);
   series  x=time     y=pred2  /
           group=patient
           lineattrs=(pattern=dash color=black);
   scatter x=minutes1 y=pcdf1  /
           markerattrs=(symbol=CircleFilled size=9);
   scatter x=minutes2 y=pcdf2  /
           markerattrs=(symbol=Circle       size=9);
run;

The separation of the distribution functions by groups is evident in Output 83.5.12. Most of the distributions of patients in the first group are to the left of the distributions in the second group. The separation is not complete, however. Several patients who are assigned the second pain reliever experience headache relief more quickly than patients assigned to the first group.

Output 83.5.12: Patient-Specific CDFs and Predicted Values. Pain Reliever 1: Solid Lines, Closed Circles; Pain Reliever 2: Dashed Lines, Open Circles.

Patient-Specific CDFs and Predicted Values. Pain Reliever 1: Solid Lines, Closed Circles; Pain Reliever 2: Dashed Lines, Open Circles.