<?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 Re: Transfer code from GLIMMIX to NLMIXED (for NB and ZINB) in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Transfer-code-from-GLIMMIX-to-NLMIXED-for-NB-and-ZINB/m-p/506399#M26022</link>
    <description>&lt;P&gt;It is certainly possible to do this analysis with PROC NLMIXED, but you might consider using PROC FMM instead. There is &lt;A href="https://go.documentation.sas.com/?docsetId=statug&amp;amp;docsetVersion=14.3&amp;amp;docsetTarget=statug_fmm_gettingstarted02.htm&amp;amp;locale=en" target="_self"&gt;a Getting Started example in the doc&lt;/A&gt;&amp;nbsp;that shows how to run a zero-inflated Poisson model. If you follow that example but change the distribution to DIST=NEGBIN, I think PROC FMM can&amp;nbsp;solve your problem. If I'm wrong, write back and someone can help you with NLMIXED.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Oct 2018 11:45:35 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2018-10-22T11:45:35Z</dc:date>
    <item>
      <title>Transfer code from GLIMMIX to NLMIXED (for NB and ZINB)</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Transfer-code-from-GLIMMIX-to-NLMIXED-for-NB-and-ZINB/m-p/505969#M26014</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;My goal is to fit a longitudinal zero-inflated negative binomial model to my data. &lt;/SPAN&gt;&lt;SPAN&gt;To my knowledge, proc mixed does not provide other distributions than normal; &lt;/SPAN&gt;&lt;SPAN&gt;proc genmod has a repeated statement, but not for ZINB; &lt;/SPAN&gt;&lt;SPAN&gt;and proc glimmix has a random statement for the NB, but not ZINB. So in the end I'll have to work with PROC NLMIXED.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Since I have not yet worked with NLMIXED, I try to proceed step by step. &lt;/SPAN&gt;&lt;SPAN&gt;For now I work under the assumption that a negative binomial distribution is sufficient and I would like to transfer my GLIMMIX code into NLMIXED. &lt;/SPAN&gt;&lt;SPAN&gt;Here I come across the problem that I'm not sure about choosing the right random effects.&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;The data is the following:&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;There are 36 samples. &lt;/SPAN&gt;&lt;SPAN&gt;The samples were split into two sub-samples and stored once at 5 degrees and once at 17 degrees. &lt;/SPAN&gt;&lt;SPAN&gt;The sub-samples were measured at the beginning, after 24 h and after 72 h. &lt;/SPAN&gt;&lt;SPAN&gt;Altogether, the dataset contains 216 observations (with the variables POOL: 1-36, TEMPERATUR: 5/17, ZP: 0/24/72) for the number of germs (KEIMZAHL).&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Here is a plot of the data, separated according to the temperature:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="KeimVerlauf.PNG" style="width: 600px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24180i3C0B955708D5A92F/image-size/large?v=v2&amp;amp;px=999" role="button" title="KeimVerlauf.PNG" alt="KeimVerlauf.PNG" /&gt;&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Now I wonder how to properly specify the dependency and hierarchy in my data in the code. &lt;/SPAN&gt;&lt;SPAN&gt;Is it correct that I indicate the dependency in GLIMMIX with a random statement like this?&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; random int / subject = pool;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;and the hierarchy&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp; random ZP / subject = temperature (pool) type = cs residual;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;(For the sake of simplicity, I chose "cs" as the correlation structure. The times are not equidistant, so we can discuss this. )&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Overall, my code looks like this:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC GLIMMIX DATA = FV1_2016;
nloptions maxiter = 1000;
  CLASS Pool ZP (ref = "0") Temperatur (ref = "5");
  MODEL Keimzahl = Temperatur | ZP / s dist = negbin;
  random int / subject = pool;
  random ZP / subject = Temperatur(Pool) type = cs residual;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;I am able to transfer the first part to NLMIXED. Again I am not sure about defining random effects in NLMIXED. &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;For NLMIXED I have to restructure my record. I do this:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;DATA FV1_2016;
 SET FV1_2016;
/ * Temperature as a dummy * /
 IF Temperatur = 17 THEN dummy_temp17 = 1;
ELSE dummy_temp17 = 0;

/ * Time as a dummy * /
IF ZP = 24 THEN dummy_zp24 = 1;
ELSE dummy_zp24 = 0;
IF ZP = 72 THEN dummy_zp72 = 1;
ELSE dummy_zp72 = 0;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&lt;BR /&gt;My NLMIXED looks like this:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc nlmixed data = FV1_2016 qpoints = 10 max = 500;
  parms b0 = 6.58 b1 = -1.75 b2 = -0.41 b3 = -0.87 b4 = -1.73 b5 = 1.68 alpha = 0.1 sigma2b = 0.1 to 10.1 by 1 sigma2b1 = 0.1 to 10.1 by 1;
  mu = exp (b0 + b1 * dummy_temp17 + b2 * dummy_zp24 + b3 * dummy_zp72 + b4 * dummy_temp17 * dummy_zp24 + b5 * dummy_temp17 * dummy_zp72 + c0 + c1 * ZP);
  model Keimzahl ~ negbin (1 / alpha, 1 / (1 + mu * alpha));
  random c0 c1 ~ normal ([0, 0], [sigma2b, 0, sigma2b1]) subject = pool;
  predict mu out = means;
  ods output ParameterEstimates = est_random;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;&lt;BR /&gt;I realize that this produces different results because the REs are not set properly yet.&lt;BR /&gt;&lt;BR /&gt;I have a few more questions, but I would like to ask this one first and then work on it a little bit before asking the next one.&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;SPAN&gt;Your help is very welcome!&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Oct 2018 07:24:09 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Transfer-code-from-GLIMMIX-to-NLMIXED-for-NB-and-ZINB/m-p/505969#M26014</guid>
      <dc:creator>lotcarrots</dc:creator>
      <dc:date>2018-10-20T07:24:09Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer code from GLIMMIX to NLMIXED (for NB and ZINB)</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Transfer-code-from-GLIMMIX-to-NLMIXED-for-NB-and-ZINB/m-p/506399#M26022</link>
      <description>&lt;P&gt;It is certainly possible to do this analysis with PROC NLMIXED, but you might consider using PROC FMM instead. There is &lt;A href="https://go.documentation.sas.com/?docsetId=statug&amp;amp;docsetVersion=14.3&amp;amp;docsetTarget=statug_fmm_gettingstarted02.htm&amp;amp;locale=en" target="_self"&gt;a Getting Started example in the doc&lt;/A&gt;&amp;nbsp;that shows how to run a zero-inflated Poisson model. If you follow that example but change the distribution to DIST=NEGBIN, I think PROC FMM can&amp;nbsp;solve your problem. If I'm wrong, write back and someone can help you with NLMIXED.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 11:45:35 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Transfer-code-from-GLIMMIX-to-NLMIXED-for-NB-and-ZINB/m-p/506399#M26022</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2018-10-22T11:45:35Z</dc:date>
    </item>
    <item>
      <title>Re: Transfer code from GLIMMIX to NLMIXED (for NB and ZINB)</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Transfer-code-from-GLIMMIX-to-NLMIXED-for-NB-and-ZINB/m-p/506458#M26024</link>
      <description>&lt;P&gt;Thank you for your reference to PROC FMM, which is also new to me and therefore very interesting. I looked at your example and also read this paper &lt;A href="https://support.sas.com/rnd/app/stat/papers/abstracts/328-2012.html" target="_blank"&gt;https://support.sas.com/rnd/app/stat/papers/abstracts/328-2012.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;in which the link to the hurdle-model became clearer to me.&lt;/P&gt;&lt;P&gt;However, I am not able to include a random effect for my repeated measurements in PROC FMM, since it is only for use with fixed effects, am I right? Furthermore, the ref statements do not work. Is it possible to change the reference categories in PROC FMM? Thirdly, i&lt;SPAN class=""&gt;f I just look at the fit statistics of the two models, NB and ZINB, in PROC FMM, then my Pearson statistic suddenly gets larger. Why this?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN class=""&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FitStats_NB_ZINB.PNG" style="width: 462px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24235iB127E2DEF17702AF/image-size/large?v=v2&amp;amp;px=999" role="button" title="FitStats_NB_ZINB.PNG" alt="FitStats_NB_ZINB.PNG" /&gt;&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Added: This would be my mixture model&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fmm data=FV1_2016;
class Pool ZP Temperatur;
model Keimzahl = Temperatur|ZP / dist=negbin; /* not truncated, zeros can come from both components */
model Keimzahl =             / dist=Constant; /* constant distr for the zero group */
output out = fmm_ZINB residual pred;
run;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;SPAN class="short_text"&gt;&lt;SPAN class=""&gt;Unfortunately, the residuals do not look that good either:&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FMM_NB_Residuals.PNG" style="width: 400px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24237i15A959CC3F14C5D0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="FMM_NB_Residuals.PNG" alt="FMM_NB_Residuals.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After some considerations, I came to the following conclusion with my approach in GLIMMIX:&lt;/P&gt;&lt;P&gt;I just need a random effect for the repetitions, i.e. a two-way model with paired samples and repeated measurements. This should work with&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;PROC GLIMMIX DATA=FV1_2016;
nloptions maxiter=1000;
CLASS Pool ZP Temperatur;
MODEL Keimzahl =  Temperatur|ZP / s dist=negbin;
random _residual_ / subject=Pool type=UN;
LSMEANS ZP|Temperatur;
RUN;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;Do you think that it is sufficient? Just weird that it only converges with UN or ar(1) as covariance structure, which does not make it any easier for my idea with PROC NLMIXED. &lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="FitStats_NB_UN_AR1.PNG" style="width: 560px;"&gt;&lt;img src="https://communities.sas.com/t5/image/serverpage/image-id/24238iD79A493232BE2089/image-size/large?v=v2&amp;amp;px=999" role="button" title="FitStats_NB_UN_AR1.PNG" alt="FitStats_NB_UN_AR1.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;How can I compare both the UN-model and the AR(1)-model in terms of AIC? Actually, I do not have equal spacing, thus I would prefer the second model.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I really appreciate your feedback on my thoughts and questions.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Oct 2018 15:26:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Transfer-code-from-GLIMMIX-to-NLMIXED-for-NB-and-ZINB/m-p/506458#M26024</guid>
      <dc:creator>lotcarrots</dc:creator>
      <dc:date>2018-10-22T15:26:52Z</dc:date>
    </item>
  </channel>
</rss>

