<?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 proc nlmixed for custom log likelihood in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/proc-nlmixed-for-custom-log-likelihood/m-p/963595#M48324</link>
    <description>&lt;P&gt;hello, I'm trying to code up the likelihood below using Proc NLMIXED.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have dataset that is person period, sorted by id and time. here is the structure of dataset, sorted by ID and time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 240pt;" border="0" width="320" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 48pt;" span="5" width="64" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="64" height="19" class="xl66" style="height: 14.4pt; width: 48pt;"&gt;ID&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;Time&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;y (Event)&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;last_ob&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;x1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;21&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;12&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;23&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;5&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;23&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;6&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;7&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Forecaster_0-1744035604814.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105971i9F45E110782FDAC7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Forecaster_0-1744035604814.png" alt="Forecaster_0-1744035604814.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is the sas proc NLMIXED code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc nlmixed data=your_data qpoints=50;
   parms mu=0 sigma2=1 beta1=0;
   bounds sigma2 &amp;gt; 0;

   /* Linear predictor */
   linpred = eta + beta1*x1;
   theta = exp(linpred) / (1 + exp(linpred));
   log_surv = log(1 - theta);

   /* Accumulate log survival up to time t-1 using ZLAG */
   if time = 1 then acc_log_surv = 0;
   else acc_log_surv = ZLAG(acc_log_surv) + ZLAG(log_surv);

   /* Event or censoring contribution */
   if y = 1 then loglik = acc_log_surv + log(theta);
   else if last_obs = 1 then loglik = acc_log_surv + log(1 - theta);
   else loglik = .;

   model y ~ general(loglik);
   random eta ~ normal(mu, sigma2) subject=id;
run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have two part question,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what would "y" in model general(loglik) be? and also how do I code up cumulative product (or log sum) of P(T) and S(T) since retain and first.id is not available. I just used zlag based on time = 1? is this correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sri&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Apr 2025 14:46:15 GMT</pubDate>
    <dc:creator>Forecaster</dc:creator>
    <dc:date>2025-04-07T14:46:15Z</dc:date>
    <item>
      <title>proc nlmixed for custom log likelihood</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/proc-nlmixed-for-custom-log-likelihood/m-p/963595#M48324</link>
      <description>&lt;P&gt;hello, I'm trying to code up the likelihood below using Proc NLMIXED.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have dataset that is person period, sorted by id and time. here is the structure of dataset, sorted by ID and time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;TABLE style="border-collapse: collapse; width: 240pt;" border="0" width="320" cellspacing="0" cellpadding="0"&gt;&lt;COLGROUP&gt;&lt;COL style="width: 48pt;" span="5" width="64" /&gt; &lt;/COLGROUP&gt;
&lt;TBODY&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD width="64" height="19" class="xl66" style="height: 14.4pt; width: 48pt;"&gt;ID&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;Time&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;y (Event)&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;last_ob&lt;/TD&gt;
&lt;TD width="64" class="xl66" style="border-left: none; width: 48pt;"&gt;x1&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;21&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;20&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;12&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;2&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;23&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;4&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;5&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;23&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;6&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;10&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR style="height: 14.4pt;"&gt;
&lt;TD height="19" align="right" class="xl65" style="height: 14.4pt; border-top: none;"&gt;3&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;7&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;0&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;1&lt;/TD&gt;
&lt;TD align="right" class="xl65" style="border-top: none; border-left: none;"&gt;5&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Forecaster_0-1744035604814.png" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/105971i9F45E110782FDAC7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Forecaster_0-1744035604814.png" alt="Forecaster_0-1744035604814.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is the sas proc NLMIXED code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;proc nlmixed data=your_data qpoints=50;
   parms mu=0 sigma2=1 beta1=0;
   bounds sigma2 &amp;gt; 0;

   /* Linear predictor */
   linpred = eta + beta1*x1;
   theta = exp(linpred) / (1 + exp(linpred));
   log_surv = log(1 - theta);

   /* Accumulate log survival up to time t-1 using ZLAG */
   if time = 1 then acc_log_surv = 0;
   else acc_log_surv = ZLAG(acc_log_surv) + ZLAG(log_surv);

   /* Event or censoring contribution */
   if y = 1 then loglik = acc_log_surv + log(theta);
   else if last_obs = 1 then loglik = acc_log_surv + log(1 - theta);
   else loglik = .;

   model y ~ general(loglik);
   random eta ~ normal(mu, sigma2) subject=id;
run;
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have two part question,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;what would "y" in model general(loglik) be? and also how do I code up cumulative product (or log sum) of P(T) and S(T) since retain and first.id is not available. I just used zlag based on time = 1? is this correct?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sri&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Apr 2025 14:46:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/proc-nlmixed-for-custom-log-likelihood/m-p/963595#M48324</guid>
      <dc:creator>Forecaster</dc:creator>
      <dc:date>2025-04-07T14:46:15Z</dc:date>
    </item>
    <item>
      <title>Re: proc nlmixed for custom log likelihood</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/proc-nlmixed-for-custom-log-likelihood/m-p/963666#M48326</link>
      <description>&lt;P&gt;I am not an expert in compiling codes for maximizing custom likelihoods, but I know somebody is. There is a monograph dedicated to the theory of maximum likelihood estimation as well as how to implement it in statistical softwares including SAS named &lt;A href="https://www.amazon.com/Maximum-Likelihood-Estimation-Inference-Statistics-ebook/dp/B005K04HQS/ref=sr_1_1?crid=2AWXIINZWIB6H&amp;amp;dib=eyJ2IjoiMSJ9.RO4mSSrO7wXEzjqg30vp2w.CBQc0ofvE2MRghxBq-xEiFTRsuRu0qDNibvUUXpZfsI&amp;amp;dib_tag=se&amp;amp;keywords=Maximum+Likelihood+Estimation+and+Inference+With+Examples+in+R%2C+SAS+and+ADMB&amp;amp;qid=1744104380&amp;amp;sprefix=maximum+likelihood+estimation+and+inference+with+examples+in+r%2C+sas+and+admb%2Caps%2C623&amp;amp;sr=8-1" target="_blank"&gt;Maximum Likelihood Estimation and Inference: With Examples in R, SAS and ADMB (Statistics in Practice Book 112) 1, Millar, Russell B. - Amazon.com&lt;/A&gt;. Issues on maximizing custom likelihoods via SAS procedures like PROC NLMIXED and PROC NLP are discussed frequently in that book. While waiting for an expert in the community for his/her help, you may also consult the book to see if there is anything useful. In addition, writing an e-mail to the author of the book to directly raise your question to him/her might be of help.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Apr 2025 09:32:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/proc-nlmixed-for-custom-log-likelihood/m-p/963666#M48326</guid>
      <dc:creator>Season</dc:creator>
      <dc:date>2025-04-08T09:32:11Z</dc:date>
    </item>
  </channel>
</rss>

