<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic NLMIXED: Weibull survival model with longitudinal covariate in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/NLMIXED-Weibull-survival-model-with-longitudinal-covariate/m-p/982045#M49172</link>
    <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc nlmixed data=final;
parms b0=0 b1=0 b2=0 b3=0 b4=0 b5=0 gamma=1;
bounds gamma &amp;gt; 0.2;
linp = b0 + b1*longcovar + b2* longcovar * longcovar + b3*X1 + b4*X2 + b5*X ;
alpha = exp(-linp);
eps = 1e-8;
 if aval &amp;gt; 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;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Question 1:&lt;/STRONG&gt; should the time variable (aval) be the time of the observations of longcovar or should it be the time interval value between longcovar observations?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc nlmixed data=final;
parms b0=0 b1=0 b2=0 b3=0 b4=0 b5=0 gamma=1 logsig=.1;
bounds gamma &amp;gt; 0.2;
linp = b0 + b1*longcovar + b2* longcovar * longcovar + b3*X1 + b4*X2 + b5*X  + z;
alpha = exp(-linp);
eps = 1e-8;
 if aval &amp;gt; 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;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Question 2:&lt;/STRONG&gt; Is the nlmixed code correct for the model specified, i.e., for a Weibull survival model with longitudinal covariate?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question 3&lt;/STRONG&gt;: 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?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question 4&lt;/STRONG&gt;: 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)?&lt;/P&gt;</description>
    <pubDate>Thu, 15 Jan 2026 23:21:22 GMT</pubDate>
    <dc:creator>Alan68022</dc:creator>
    <dc:date>2026-01-15T23:21:22Z</dc:date>
    <item>
      <title>NLMIXED: Weibull survival model with longitudinal covariate</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/NLMIXED-Weibull-survival-model-with-longitudinal-covariate/m-p/982045#M49172</link>
      <description>&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc nlmixed data=final;
parms b0=0 b1=0 b2=0 b3=0 b4=0 b5=0 gamma=1;
bounds gamma &amp;gt; 0.2;
linp = b0 + b1*longcovar + b2* longcovar * longcovar + b3*X1 + b4*X2 + b5*X ;
alpha = exp(-linp);
eps = 1e-8;
 if aval &amp;gt; 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;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Question 1:&lt;/STRONG&gt; should the time variable (aval) be the time of the observations of longcovar or should it be the time interval value between longcovar observations?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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):&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=""&gt;proc nlmixed data=final;
parms b0=0 b1=0 b2=0 b3=0 b4=0 b5=0 gamma=1 logsig=.1;
bounds gamma &amp;gt; 0.2;
linp = b0 + b1*longcovar + b2* longcovar * longcovar + b3*X1 + b4*X2 + b5*X  + z;
alpha = exp(-linp);
eps = 1e-8;
 if aval &amp;gt; 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;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;Question 2:&lt;/STRONG&gt; Is the nlmixed code correct for the model specified, i.e., for a Weibull survival model with longitudinal covariate?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question 3&lt;/STRONG&gt;: 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?&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Question 4&lt;/STRONG&gt;: 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)?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jan 2026 23:21:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/NLMIXED-Weibull-survival-model-with-longitudinal-covariate/m-p/982045#M49172</guid>
      <dc:creator>Alan68022</dc:creator>
      <dc:date>2026-01-15T23:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: NLMIXED: Weibull survival model with longitudinal covariate</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/NLMIXED-Weibull-survival-model-with-longitudinal-covariate/m-p/982328#M49173</link>
      <description>&lt;P&gt;Hello ,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I guess with longitudinal covariate you mean "time-varying covariate" or "time-dependent" covariate.&lt;/P&gt;
&lt;P&gt;PROC LIFREG can fit a Weibull survival model with time-varying covariate(s), but PROC LIFEREG does not allow for random effects.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, you are right ...&lt;BR /&gt;Weibull survival models with both fixed and random effects (often termed parametric frailty models) are&amp;nbsp;best implemented in SAS using&amp;nbsp;PROC NLMIXED.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Here's the example you refer to, but in a more recent version of the documentation:&lt;BR /&gt;The NLMIXED Procedure&lt;BR /&gt;&lt;SPAN&gt;Example 89.5 Failure Time and Frailty Model&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/doc/en/statug/15.3/statug_nlmixed_examples05.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/statug/15.3/statug_nlmixed_examples05.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Maybe you can find some inspiration here:&lt;BR /&gt;Paper 1492-2014 &lt;BR /&gt;Introduction to Frailty Models &lt;BR /&gt;John Amrhein, McDougall Scientific Ltd.&lt;BR /&gt;&lt;A href="https://support.sas.com/resources/papers/proceedings14/1492-2014.pdf" target="_blank"&gt;https://support.sas.com/resources/papers/proceedings14/1492-2014.pdf&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Apparently you can also fit a frailty model with PROC PHREG (PROC PHREG has a random statement), but only t&lt;SPAN&gt;wo frailty distributions are available in PROC PHREG: gamma and lognormal. Gamma and Weibull are like&amp;nbsp;cousins but tailored for different failure patterns. That's&amp;nbsp;unfortunate (Weibull not being available in PROC PHREG).&lt;BR /&gt;&lt;/SPAN&gt;The PHREG Procedure&lt;/P&gt;
&lt;P&gt;The Frailty Model&lt;/P&gt;
&lt;P&gt;&lt;A href="https://go.documentation.sas.com/doc/en/statug/latest/statug_phreg_details16.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/statug/latest/statug_phreg_details16.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Ciao and good luck with this,&lt;BR /&gt;Koen&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jan 2026 14:01:21 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/NLMIXED-Weibull-survival-model-with-longitudinal-covariate/m-p/982328#M49173</guid>
      <dc:creator>sbxkoenk</dc:creator>
      <dc:date>2026-01-22T14:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: NLMIXED: Weibull survival model with longitudinal covariate</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/NLMIXED-Weibull-survival-model-with-longitudinal-covariate/m-p/982524#M49174</link>
      <description>&lt;P&gt;Yes, sorry if my labeling was incorrect. I mean time-varying covariate.&lt;/P&gt;&lt;P&gt;Thank you for the references but I can't find anything about specifying a time-varying covariate using nlmixed.&lt;/P&gt;&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jan 2026 03:27:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/NLMIXED-Weibull-survival-model-with-longitudinal-covariate/m-p/982524#M49174</guid>
      <dc:creator>Alan68022</dc:creator>
      <dc:date>2026-01-28T03:27:52Z</dc:date>
    </item>
    <item>
      <title>Re: NLMIXED: Weibull survival model with longitudinal covariate</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/NLMIXED-Weibull-survival-model-with-longitudinal-covariate/m-p/982571#M49175</link>
      <description>&lt;P&gt;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.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You mentioned that you&amp;nbsp;&lt;SPAN&gt;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 --&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://go.documentation.sas.com/doc/en/statug/15.3/statug_phreg_examples07.htm" target="_blank"&gt;https://go.documentation.sas.com/doc/en/statug/15.3/statug_phreg_examples07.htm&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The PROC NLMIXED program does not do this counting process approach.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thanks,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jill&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 28 Jan 2026 16:58:53 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/NLMIXED-Weibull-survival-model-with-longitudinal-covariate/m-p/982571#M49175</guid>
      <dc:creator>jiltao</dc:creator>
      <dc:date>2026-01-28T16:58:53Z</dc:date>
    </item>
  </channel>
</rss>

