<?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: Seeking documentation for pdf function call for truncpoisson and truncnegbin distributions in Statistical Procedures</title>
    <link>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/618550#M29778</link>
    <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733" target="_blank"&gt;FreelanceReinhard&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;'s response is a good solution, provided that the OP is interested only in left truncation at n=0. Otherwise, the normalization constant needs to be adjusted to reflect the range of the truncation.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For an example and discussion of the truncated normal distribution, see &lt;A href="https://blogs.sas.com/content/iml/2013/07/24/the-truncated-normal-in-sas.html" target="_self"&gt;"Implement the truncated normal distribution in SAS,"&amp;nbsp;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;which uses PROC IML instead of PROC FCMP.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you wonder where those denominators came from in FreelanceReinhard's soln, they are the cumulative weights of the truncated distribution. I would have written them explicitly as&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;wt_TP = 1-pdf('poisson',0,m);&amp;nbsp; /* CDF for n&amp;gt;0 */&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;and&lt;BR /&gt;wt_TNB = 1-pdf('negb',0,p,n); /* CDF for N&amp;gt;0 */&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Jan 2020 14:21:02 GMT</pubDate>
    <dc:creator>Rick_SAS</dc:creator>
    <dc:date>2020-01-20T14:21:02Z</dc:date>
    <item>
      <title>Seeking documentation for pdf function call for truncpoisson and truncnegbin distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/618299#M29762</link>
      <description>&lt;P&gt;Hi SAS Community,&lt;/P&gt;&lt;P&gt;I am using PROC FMM (running under SAS V9.4_M5 and SAS/STAT V 14.3) to explore factors affecting counts of hospital admissions (and other similar events) for children in a large birth cohort.&amp;nbsp;As the vast majority of children in the study population do not attend hospital or experience the other events, I have lots of zero counts in the data.&lt;/P&gt;&lt;P&gt;I have found very useful tips in the SAS documentation for running zero-inflated poisson and negative binomial regression models and assessing how well those models estimate the count profiles within the data (eg usage notes &lt;A href="http://support.sas.com/kb/43/522.html" target="_self"&gt;43522&lt;/A&gt;&amp;nbsp; and this &lt;A href="https://support.sas.com/resources/papers/proceedings/pdfs/sgf2008/371-2008.pdf" target="_self"&gt;SAS Global Forum 2008 paper&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, to extend the analysis to hurdle models (eg by using the %NLEstimate macro or generating plots as demonstrated in the 2008 paper) I need to pass parameters to SAS pdf function for truncated poisson and truncated negative binomial distributions. I have run hurdle models in PROC FMM using these distributions but haven't been readily able to assess their fit or generate estimates for different covariate profiles as I can do for other distributions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To date, I have not been able to locate the correct syntax or other documentation to generate pdf estimates for truncpoisson or truncnegbin distributions. Can anyone on this forum point me in the right direction to find this documentation?&lt;/P&gt;&lt;P&gt;Many thanks in advance&lt;/P&gt;</description>
      <pubDate>Sat, 18 Jan 2020 23:50:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/618299#M29762</guid>
      <dc:creator>DomLimo</dc:creator>
      <dc:date>2020-01-18T23:50:07Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking documentation for pdf function call for truncpoisson and truncnegbin distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/618321#M29763</link>
      <description>I'm not aware of any such functions existing, but I've moved your question to the statistical forum and hopefully someone else can help you out.</description>
      <pubDate>Sun, 19 Jan 2020 03:19:00 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/618321#M29763</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-01-19T03:19:00Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking documentation for pdf function call for truncpoisson and truncnegbin distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/618327#M29764</link>
      <description>thanks Reeza</description>
      <pubDate>Sun, 19 Jan 2020 04:00:11 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/618327#M29764</guid>
      <dc:creator>DomLimo</dc:creator>
      <dc:date>2020-01-19T04:00:11Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking documentation for pdf function call for truncpoisson and truncnegbin distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/618356#M29766</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/307768"&gt;@DomLimo&lt;/a&gt;&amp;nbsp;(and&amp;nbsp;welcome to the SAS Support Communities! :-))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So, you are missing the truncated Poisson and&amp;nbsp;truncated negative binomial distributions in the list of probability distributions available in the &lt;A href="https://documentation.sas.com/?docsetId=lefunctionsref&amp;amp;docsetTarget=n164yyfgppedmkn1320boncqkh6r.htm&amp;amp;docsetVersion=9.4&amp;amp;locale=en" target="_blank" rel="noopener"&gt;PDF function&lt;/A&gt;? In this case you can create your own functions using &lt;A href="https://documentation.sas.com/?docsetId=proc&amp;amp;docsetVersion=9.4&amp;amp;docsetTarget=n0pio2crltpr35n1ny010zrfbvc9.htm&amp;amp;locale=en" target="_blank" rel="noopener"&gt;PROC FCMP&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc fcmp outlib=work.funcs.prob;
function pdf_trpoi(n,m);
  return(if n&amp;gt;0 then pdf('poisson',n,m)/(1-exp(-m)) else 0);
endsub;

function pdf_trnegb(m,p,n);
  return(if m&amp;gt;0 then pdf('negb',m,p,n)/(1-p**n) else 0);
endsub;
run;

options cmplib=work.funcs;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;After submitting the above code, functions &lt;FONT face="courier new,courier"&gt;pdf_trpoi&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;pdf_trnegb&lt;/FONT&gt; are available which compute probabilities for the &lt;EM&gt;zero-&lt;/EM&gt;truncated Poisson and &lt;EM&gt;zero-&lt;/EM&gt;truncated negative binomial distribution, respectively. The arguments of these functions are the same as those of the PDF function for the corresponding non-truncated distributions.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Example:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let lambda=2.5;

data trpoi;
do x=0 to 10;
  p=pdf('poisson',x,&amp;amp;lambda);
  tp=pdf_trpoi(x,&amp;amp;lambda);
  output;
end;
label p="Poisson(&amp;amp;lambda)"
      tp="zero-truncated Poisson(&amp;amp;lambda)";
run;

proc sgplot data=trpoi;
xaxis values=(0 to 10);
yaxis label='Probability';
scatter x=x y=p;
scatter x=x y=tp;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Given that you're working with fairly specialized models (I am not familiar with), whereas the above calculations are comparably elementary, I'm not sure if this answers your question.&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jan 2020 11:13:27 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/618356#M29766</guid>
      <dc:creator>FreelanceReinh</dc:creator>
      <dc:date>2020-01-19T11:13:27Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking documentation for pdf function call for truncpoisson and truncnegbin distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/618385#M29768</link>
      <description>&lt;P&gt;Maybe&amp;nbsp;&lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt;&amp;nbsp;can chime in when he has some time &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 19 Jan 2020 19:45:06 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/618385#M29768</guid>
      <dc:creator>Reeza</dc:creator>
      <dc:date>2020-01-19T19:45:06Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking documentation for pdf function call for truncpoisson and truncnegbin distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/618435#M29774</link>
      <description>&lt;P&gt;Hi &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for this response - it's very helpful indeed. (and thanks for the welcome!)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have been using SAS (as a "user", not programmer or developer) for decades (since SAS 6.2 or just before then) and have always been confident that it's possible to do whatever I need to do with data in SAS. However I have never used PROC FCMP and you've shown me how I can create my own functions and store them for later use...that's fantastic!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It will take me a couple of days to test the proposed solution, but it look very promising.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks very much indeed! (and thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13879"&gt;@Reeza&lt;/a&gt; for leading me to the right community forum for my question).&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, 20 Jan 2020 00:42:31 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/618435#M29774</guid>
      <dc:creator>DomLimo</dc:creator>
      <dc:date>2020-01-20T00:42:31Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking documentation for pdf function call for truncpoisson and truncnegbin distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/618550#M29778</link>
      <description>&lt;P&gt;&lt;A href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733" target="_blank"&gt;FreelanceReinhard&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;'s response is a good solution, provided that the OP is interested only in left truncation at n=0. Otherwise, the normalization constant needs to be adjusted to reflect the range of the truncation.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For an example and discussion of the truncated normal distribution, see &lt;A href="https://blogs.sas.com/content/iml/2013/07/24/the-truncated-normal-in-sas.html" target="_self"&gt;"Implement the truncated normal distribution in SAS,"&amp;nbsp;&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;which uses PROC IML instead of PROC FCMP.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If you wonder where those denominators came from in FreelanceReinhard's soln, they are the cumulative weights of the truncated distribution. I would have written them explicitly as&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;wt_TP = 1-pdf('poisson',0,m);&amp;nbsp; /* CDF for n&amp;gt;0 */&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;and&lt;BR /&gt;wt_TNB = 1-pdf('negb',0,p,n); /* CDF for N&amp;gt;0 */&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Jan 2020 14:21:02 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/618550#M29778</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-01-20T14:21:02Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking documentation for pdf function call for truncpoisson and truncnegbin distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/619013#M29798</link>
      <description>&lt;P&gt;Thanks all for this prompt assistance. Thanks &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/13684"&gt;@Rick_SAS&lt;/a&gt; for the clarification of the denominators in &lt;a href="https://communities.sas.com/t5/user/viewprofilepage/user-id/32733"&gt;@FreelanceReinh&lt;/a&gt; 's solution. As I'm only interested in truncation at n=0 for the time-being, this solution meets my immediate requirements.&lt;/P&gt;&lt;P&gt;This has been a very positive first foray into the SAS Community forum.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 01:18:42 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/619013#M29798</guid>
      <dc:creator>DomLimo</dc:creator>
      <dc:date>2020-01-22T01:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Seeking documentation for pdf function call for truncpoisson and truncnegbin distributions</title>
      <link>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/619082#M29800</link>
      <description>&lt;P&gt;We are glad that you got a solution and found the forum helpful and friendly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sometimes tne "experts" disagree over the choice of the "accepted" solution. I suggest you select FrelanceReihhard's answer, not mine, as the solution to your question. He provided a correct set of formulas and a working program.&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jan 2020 10:18:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/Statistical-Procedures/Seeking-documentation-for-pdf-function-call-for-truncpoisson-and/m-p/619082#M29800</guid>
      <dc:creator>Rick_SAS</dc:creator>
      <dc:date>2020-01-22T10:18:10Z</dc:date>
    </item>
  </channel>
</rss>

