<?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: Hurdle model with negative binomial in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Hurdle-model-with-negative-binomial/m-p/12388#M174</link>
    <description>Dale makes a good point: it is best to avoid using parameter bounds, when possible. For your model, it should be possible to avoid explicit bounds, using the recommendations from Dale. With some nonlinear models, it can be challenging to do the optimization without using bounds, but always a good goal.</description>
    <pubDate>Tue, 14 Jun 2011 18:57:40 GMT</pubDate>
    <dc:creator>lvm</dc:creator>
    <dc:date>2011-06-14T18:57:40Z</dc:date>
    <item>
      <title>Hurdle model with negative binomial</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Hurdle-model-with-negative-binomial/m-p/12385#M171</link>
      <description>Hi,&lt;BR /&gt;
I am trying to do a hurdle model with a truncated negative binomial&lt;BR /&gt;
distribution instead of a poisson.  I keep getting the error message:&lt;BR /&gt;
&lt;BR /&gt;
"NOTE: Execution error for observation 1."&lt;BR /&gt;
&lt;BR /&gt;
I have tried setting the initial parameters to zero, 1 and -1.  But I still&lt;BR /&gt;
get the same message.  The code I am running is:&lt;BR /&gt;
&lt;BR /&gt;
options ls=74 ps=100 nodate nocenter pageno=1;&lt;BR /&gt;
Data main;&lt;BR /&gt;
input salinity male female court;&lt;BR /&gt;
mf = male*female;&lt;BR /&gt;
sf = salinity*female;&lt;BR /&gt;
sm = salinity*male;&lt;BR /&gt;
smf= salinity*male*female;&lt;BR /&gt;
;&lt;BR /&gt;
cards;&lt;BR /&gt;
0    1    1    0&lt;BR /&gt;
0    1    1    0&lt;BR /&gt;
0    1    1    29&lt;BR /&gt;
...more data......&lt;BR /&gt;
;&lt;BR /&gt;
&lt;BR /&gt;
proc sort data=main;&lt;BR /&gt;
by male female salinity;&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
proc nlmixed data = main;&lt;BR /&gt;
parms a0 = 0 a1 = 0 a2 =0 a3=0 b0 = 0 b1 = 0 b2 = 0 b3 = 0 b4 = 0 b5 = 0 b6 =&lt;BR /&gt;
0 b7 = 0 alpha=0;&lt;BR /&gt;
eta0 = a0 + a1 * male + a2 *female + a3 *mf;&lt;BR /&gt;
etap = b0 + b1 * male + b2 * female + b3 * mf + b4 * salinity +&lt;BR /&gt;
b5 * sm + b6 * sf + b7 *smf;&lt;BR /&gt;
exp_eta0 = exp(eta0);&lt;BR /&gt;
mu = exp(etap);&lt;BR /&gt;
p0 = exp_eta0 / (1 + exp_eta0);&lt;BR /&gt;
m=1/alpha;&lt;BR /&gt;
if court = 0 then ll = log(p0);&lt;BR /&gt;
else ll = lgamma(court+m)-lgamma(court+1)-lgamma(m) + court*log(alpha*mu)-&lt;BR /&gt;
(court+m)*log(1+alpha*mu)- log(1 -( 1 + alpha*mu)**(-m));&lt;BR /&gt;
model court ~ general(ll);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
Any help would be greatly appreciated!!,&lt;BR /&gt;
Emma</description>
      <pubDate>Mon, 13 Jun 2011 20:36:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Hurdle-model-with-negative-binomial/m-p/12385#M171</guid>
      <dc:creator>eberdan</dc:creator>
      <dc:date>2011-06-13T20:36:42Z</dc:date>
    </item>
    <item>
      <title>Re: Hurdle model with negative binomial</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Hurdle-model-with-negative-binomial/m-p/12386#M172</link>
      <description>More than likely, your program is trying to take a log of 0 (including lgamma of 0), or creating infinity. For instance, with alpha=0 (starting value), m=1/alpha will cause big problems (infinity). Also, there are log or lgamma functions that involve alpha (which will also blow up with 0 for alpha). I took your data and added a few more dummy data points. The program ran when I used 1 for the starting value of alpha. But this is still dangerous, because parameter estimates can migrate to 'impossible' regions during the optimization. You should look into putting bounds on the parameters. Check out the syntax of the bounds statement.&lt;BR /&gt;
(I did not really look at the rest of the code to see if the customized ll is correct).</description>
      <pubDate>Tue, 14 Jun 2011 02:52:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Hurdle-model-with-negative-binomial/m-p/12386#M172</guid>
      <dc:creator>lvm</dc:creator>
      <dc:date>2011-06-14T02:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: Hurdle model with negative binomial</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Hurdle-model-with-negative-binomial/m-p/12387#M173</link>
      <description>The hurdle log-likelihood function does appear sound.  As lvm has indicated, computing 1/alpha for alpha initialized to 0 is a problem.&lt;BR /&gt;
&lt;BR /&gt;
Personally, I prefer not to use bounds statements to control acceptable values for the parameters.  Derivatives are usually not defined when parameter estimates are fixed at boundary values.  Sometimes, the function itself is not defined when a parameter takes on the boundary value.  (Such is the case for the NB distribution when you specify alpha=0.  Even though the NB is a Poisson when alpha=0, it is not possible to compute the Poisson density using a negative binomial density function.)&lt;BR /&gt;
&lt;BR /&gt;
Instead of using boundary constraints, consider parameterizing the model so that the parameter estimates are always in an acceptable range.  For instance, in the NB distribution, the parameter alpha must always be positive.  If you name log_alpha as a parameter and then compute alpha=exp(log_alpha), then alpha&amp;gt;0 for -infinity&lt;LOG_ALPHA. as="" long="" as="" log_alpha="" is="" finite=""&gt;&lt;/LOG_ALPHA.&gt;</description>
      <pubDate>Tue, 14 Jun 2011 17:07:54 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Hurdle-model-with-negative-binomial/m-p/12387#M173</guid>
      <dc:creator>Dale</dc:creator>
      <dc:date>2011-06-14T17:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Hurdle model with negative binomial</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Hurdle-model-with-negative-binomial/m-p/12388#M174</link>
      <description>Dale makes a good point: it is best to avoid using parameter bounds, when possible. For your model, it should be possible to avoid explicit bounds, using the recommendations from Dale. With some nonlinear models, it can be challenging to do the optimization without using bounds, but always a good goal.</description>
      <pubDate>Tue, 14 Jun 2011 18:57:40 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Hurdle-model-with-negative-binomial/m-p/12388#M174</guid>
      <dc:creator>lvm</dc:creator>
      <dc:date>2011-06-14T18:57:40Z</dc:date>
    </item>
    <item>
      <title>Re: Hurdle model with negative binomial</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Hurdle-model-with-negative-binomial/m-p/12389#M175</link>
      <description>Thank you all for your advice!  I took Dale's advice and the model works.  However, I am concerned that the hurdle part of the model is not working.   My current code is not very different:&lt;BR /&gt;
&lt;BR /&gt;
proc nlmixed data = main;&lt;BR /&gt;
parms a0 = 0 a1 = 0 a2 =0 a3=0 b0 = 0 b1 = 0 b2 = 0 b3 = 0 b4 = 0 b5 = 0 b6 = 0 b7 = 0 log_alpha=0;&lt;BR /&gt;
eta0 = a0 + a1 * male + a2 *female + a3 *mf; &lt;BR /&gt;
etap = b0 + b1 * male + b2 * female + b3 * mf + b4 * salinity +&lt;BR /&gt;
b5 * sm + b6 * sf + b7 *smf;&lt;BR /&gt;
exp_eta0 = exp(eta0); &lt;BR /&gt;
alpha = exp(log_alpha);&lt;BR /&gt;
mu = exp(etap);&lt;BR /&gt;
p0 = exp_eta0 / (1 + exp_eta0);&lt;BR /&gt;
m= 1/alpha;&lt;BR /&gt;
if court = 0 then ll = log(p0);&lt;BR /&gt;
else ll = lgamma(court+m)-lgamma(court+1)-lgamma(m) + court*log(alpha*mu)-(court+m)*log(1+alpha*mu)- log(1 -( 1 + alpha*mu)**(-m));&lt;BR /&gt;
model court ~ general(ll);&lt;BR /&gt;
run;&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
which is almost identical to what I have before.  But my parameter estimates come out like this:&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
                                Standard&lt;BR /&gt;
Parameter  Estimate     Error    DF  t Value  Pr &amp;gt; |t|   Alpha     Lower&lt;BR /&gt;
&lt;BR /&gt;
a0              2.1240   2840.01   132     0.00    0.9994    0.05  -5615.70&lt;BR /&gt;
a1              2.9631   2808.80   132     0.00    0.9992    0.05  -5553.13&lt;BR /&gt;
a2              3.2490   2820.91   132     0.00    0.9991    0.05  -5576.80&lt;BR /&gt;
a3              4.2013   2814.01   132     0.00    0.9988    0.05  -5562.20&lt;BR /&gt;
b0              2.9783    4.3967   132     0.68    0.4993    0.05   -5.7188&lt;BR /&gt;
b1            -0.06676    2.4206   132    -0.03    0.9780    0.05   -4.8549&lt;BR /&gt;
b2             -0.2695    4.1330   132    -0.07    0.9481    0.05   -8.4451&lt;BR /&gt;
b3              0.1722    2.1445   132     0.08    0.9361    0.05   -4.0698&lt;BR /&gt;
b4              5.3092    0.3373   132    15.74    &amp;lt;.0001    0.05    4.6420&lt;BR /&gt;
b5             -2.6839    0.1903   132   -14.10    &amp;lt;.0001    0.05   -3.0604&lt;BR /&gt;
b6             -5.2397    0.3102   132   -16.89    &amp;lt;.0001    0.05   -5.8533&lt;BR /&gt;
b7              2.6524    0.1629   132    16.28    &amp;lt;.0001    0.05    2.3301&lt;BR /&gt;
log_alpha    0.2495    0.2317   132     1.08    0.2834    0.05   -0.2087&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
So the standard errors for the hurdle part of the model are huge!   I can play around with the starting value of log_alpha and get them somewhat better but they are still huge.  I also tried changing the hurdle model.  Right now it is log((exp(zeromodel)) /(1+(exp(zeromodel))).  Based on the SAS for mixed models by Littell et al's hurdle poisson I changed it to -exp(zeromodel) but that did not change the outcome.&lt;BR /&gt;
&lt;BR /&gt;
-Emma</description>
      <pubDate>Tue, 14 Jun 2011 19:14:34 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Hurdle-model-with-negative-binomial/m-p/12389#M175</guid>
      <dc:creator>eberdan</dc:creator>
      <dc:date>2011-06-14T19:14:34Z</dc:date>
    </item>
  </channel>
</rss>

