I'm looking for help using SAS to fit a Weibull survival model with longitudinal covariate. I modified code I found in SAS documentation: SAS/STAT 9.22 User's Guide Example 61.5 Failure Time and Frailty Model. The objective of the modeling is to determine if the longitudinal covariate is important for explaining variability in survival times, i.e., when the longitudinal covariate goes up more, is there a higher probability of death? However, the code I found in the documentation did not have a longitudinal covariate.
In my code below I attempted to include a longitudinal covariate called longcovar and X1-X3 are other covariates that are constant over time. Aval is the time variable. Although the model is quadratic in the longitudinal covariate shown below, I also looked at quadratic.
proc nlmixed data=final;
parms b0=0 b1=0 b2=0 b3=0 b4=0 b5=0 gamma=1;
bounds gamma > 0.2;
linp = b0 + b1*longcovar + b2* longcovar * longcovar + b3*X1 + b4*X2 + b5*X ;
alpha = exp(-linp);
eps = 1e-8;
if aval > 0 then do;
G_t = exp(-(alpha*aval)**gamma);
g = gamma*alpha*((alpha*aval)**(gamma-1))*G_t;
ll = (CNSR_deatheq0=0)*log(g + eps)
+ (CNSR_deatheq0=1)*log(G_t + eps);
end;
else ll = .;
model aval ~ general(ll);
run;Question 1: should the time variable (aval) be the time of the observations of longcovar or should it be the time interval value between longcovar observations?
After I used the above code, I added a random effect for subject. Each subject has their own set of covariate values. The change in the code is as follows (but with an overly simple covariance matrix and not showing how the starting values could be updated from the linear model results):
proc nlmixed data=final;
parms b0=0 b1=0 b2=0 b3=0 b4=0 b5=0 gamma=1 logsig=.1;
bounds gamma > 0.2;
linp = b0 + b1*longcovar + b2* longcovar * longcovar + b3*X1 + b4*X2 + b5*X + z;
alpha = exp(-linp);
eps = 1e-8;
if aval > 0 then do;
G_t = exp(-(alpha*aval)**gamma);
g = gamma*alpha*((alpha*aval)**(gamma-1))*G_t;
ll = (CNSR_deatheq0=0)*log(g + eps)
+ (CNSR_deatheq0=1)*log(G_t + eps);
end;
else ll = .;
model aval ~ general(ll);
random z ~ normal(0,exp(2*logsig)) subject=ID;
run;Question 2: Is the nlmixed code correct for the model specified, i.e., for a Weibull survival model with longitudinal covariate?
Question 3: The algorithm converged for the fixed effects models. I believe the difficulty I had with the random models (nonconvergence and wild parameter values) is due to each subject having different covariate values, i.e., including the random effect z resulted in over-parameterization. Does this seem like a reasonable explanation?
Question 4: The longitudinal covariate was only available for subjects who were censored. If subjects had died, then the measurement could not be taken. We used LOCF as what we believe is a conservative value for the longitudinal covariate knowing that there will be bias, more so for those with larger intervals between the last observation and death. How unreasonable is this (other than as a measure of reasonableness being the size of the time interval)?
Hello ,
I guess with longitudinal covariate you mean "time-varying covariate" or "time-dependent" covariate.
PROC LIFREG can fit a Weibull survival model with time-varying covariate(s), but PROC LIFEREG does not allow for random effects.
So, you are right ...
Weibull survival models with both fixed and random effects (often termed parametric frailty models) are best implemented in SAS using PROC NLMIXED.
Here's the example you refer to, but in a more recent version of the documentation:
The NLMIXED Procedure
Example 89.5 Failure Time and Frailty Model
https://go.documentation.sas.com/doc/en/statug/15.3/statug_nlmixed_examples05.htm
Maybe you can find some inspiration here:
Paper 1492-2014
Introduction to Frailty Models
John Amrhein, McDougall Scientific Ltd.
https://support.sas.com/resources/papers/proceedings14/1492-2014.pdf
Apparently you can also fit a frailty model with PROC PHREG (PROC PHREG has a random statement), but only two frailty distributions are available in PROC PHREG: gamma and lognormal. Gamma and Weibull are like cousins but tailored for different failure patterns. That's unfortunate (Weibull not being available in PROC PHREG).
The PHREG Procedure
The Frailty Model
https://go.documentation.sas.com/doc/en/statug/latest/statug_phreg_details16.htm
Ciao and good luck with this,
Koen
Yes, sorry if my labeling was incorrect. I mean time-varying covariate.
Thank you for the references but I can't find anything about specifying a time-varying covariate using nlmixed.
I was able to fit the model in nlmixed and in lifereg but the output didn't match. I assume it's because I used the counting process approach in lifereg and not in nlmixed. My understanding is that using the counting process approach in lifereg results in specifying time at risk for each observation since the last observation and not the cumulative time since baseline. I believe nlmixed, as I coded it, does the latter which explains why my results are different. I wanted the latter, but without documentation, I can't be sure that I coded it correctly. I'm still hoping someone can help me out.
Your NLMIXED program seems to fit a random intercept model. As long as each subject has multiple observations, I do not think it is overparameterized. The nonconvergence can have a variety of causes. Sometimes, rescaling some of the variable values, reparameterizing the model, or providing different starting values can help with the convergence issues.
You mentioned that you used the counting process approach in lifereg....I am not sure exactly how you did it, but this example in the PROC PHREG documentation can be a good reference for this approach --
https://go.documentation.sas.com/doc/en/statug/15.3/statug_phreg_examples07.htm
The PROC NLMIXED program does not do this counting process approach.
Thanks,
Jill
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.
Find more tutorials on the SAS Users YouTube channel.