<?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: simulation from negative binomail distribution in SAS Procedures</title>
    <link>https://communities.sas.com/t5/SAS-Procedures/simulation-from-negative-binomail-distribution/m-p/371650#M65142</link>
    <description>&lt;PRE&gt; It looks good.  
Value/DF is near  1 .

&lt;/PRE&gt;</description>
    <pubDate>Thu, 29 Jun 2017 12:29:37 GMT</pubDate>
    <dc:creator>Ksharp</dc:creator>
    <dc:date>2017-06-29T12:29:37Z</dc:date>
    <item>
      <title>simulation from negative binomail distribution</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simulation-from-negative-binomail-distribution/m-p/370418#M65100</link>
      <description>&lt;P&gt;I am using base sas 9.4. Now I am working on Simulating data.&lt;/P&gt;&lt;P&gt;After I fitted data to negative binomial distribution using the following code ;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;proc countreg data=claim;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; model y = / dist=negbin;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output out=exp_nb prob=prob_nb;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; freq freq;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc format;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; value yfmt&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7-high = "&amp;gt;=7";&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc means sum nway data=exp_nb;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; class y;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; var prob_nb;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format y yfmt.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; output out=exp_nb sum=_testp_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; data exp_nb;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; set exp_nb;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sumexp + _testp_;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; sumtolast = lag(sumexp);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if y=7 then _testp_ = 1 - sumtolast;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proc freq data=claims;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; table y / chisq(testp=exp_nb df=-2 lrchisq);&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; format y yfmt.;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; weight freq;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; run;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I got&amp;nbsp;only p-value from fitting this data.&lt;/P&gt;&lt;P&gt;Now I want to simulate data from negative binomial distribution.&lt;/P&gt;&lt;P&gt;How can&amp;nbsp;I do that ? please help&lt;/P&gt;&lt;P&gt;(version of sas program&amp;nbsp;do not have Proc iml procedure)&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 07:16:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simulation-from-negative-binomail-distribution/m-p/370418#M65100</guid>
      <dc:creator>Peaw</dc:creator>
      <dc:date>2017-06-26T07:16:55Z</dc:date>
    </item>
    <item>
      <title>Re: simulation from negative binomail distribution</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simulation-from-negative-binomail-distribution/m-p/370437#M65102</link>
      <description>&lt;P&gt;You can simulate data from a negative binomial distribution using the RAND function like this&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;data negbin;
	do x = 1 to 1000;
		y = rand('negbinomial', 0.5, 2);
		output;
	end;
run;

title 'Plot the Simulated Data';
proc sgplot data = negbin;
	histogram y;
run;
title;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Adjust p and k to your liking. The documentation is here&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001466748.htm" target="_blank"&gt;http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001466748.htm&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 06:31:41 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simulation-from-negative-binomail-distribution/m-p/370437#M65102</guid>
      <dc:creator>PeterClemmensen</dc:creator>
      <dc:date>2017-06-26T06:31:41Z</dc:date>
    </item>
    <item>
      <title>Re: simulation from negative binomail distribution</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simulation-from-negative-binomail-distribution/m-p/370441#M65103</link>
      <description>&lt;P&gt;could you please tell me that how can I know p of this&amp;nbsp;data from fitting the distribution.&lt;/P&gt;&lt;P&gt;because when&amp;nbsp;I fitted this distribution I fitted from raw data of frequency of claim of each auto policy. That's why I do not know P of this data.&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 07:23:32 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simulation-from-negative-binomail-distribution/m-p/370441#M65103</guid>
      <dc:creator>Peaw</dc:creator>
      <dc:date>2017-06-26T07:23:32Z</dc:date>
    </item>
    <item>
      <title>Re: simulation from negative binomail distribution</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simulation-from-negative-binomail-distribution/m-p/370575#M65110</link>
      <description>&lt;P&gt;Ha. Here is.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://blogs.sas.com/content/iml/2012/04/04/fitting-a-poisson-distribution-to-data-in-sas.html" target="_blank"&gt;http://blogs.sas.com/content/iml/2012/04/04/fitting-a-poisson-distribution-to-data-in-sas.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;proc genmod data=MyData;
   model N = / dist=negbin;
   output out=Fit p=lambda;
run;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://support.sas.com/kb/24/166.html" target="_blank"&gt;http://support.sas.com/kb/24/166.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Jun 2017 14:18:10 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simulation-from-negative-binomail-distribution/m-p/370575#M65110</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-06-26T14:18:10Z</dc:date>
    </item>
    <item>
      <title>Re: simulation from negative binomail distribution</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simulation-from-negative-binomail-distribution/m-p/371517#M65141</link>
      <description>&lt;P&gt;I am sorry to bother you. But after following your suggestion&amp;nbsp;I got the attached output.&lt;/P&gt;&lt;P&gt;How can I know this model fits the data or not.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;BR /&gt;&lt;IMG src="https://communities.sas.com/t5/image/serverpage/image-id/14000i20A82B0CD0914A6A/image-size/large?v=1.0&amp;amp;px=600" border="0" alt="Capture.JPG" title="Capture.JPG" /&gt;</description>
      <pubDate>Thu, 29 Jun 2017 03:30:23 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simulation-from-negative-binomail-distribution/m-p/371517#M65141</guid>
      <dc:creator>Peaw</dc:creator>
      <dc:date>2017-06-29T03:30:23Z</dc:date>
    </item>
    <item>
      <title>Re: simulation from negative binomail distribution</title>
      <link>https://communities.sas.com/t5/SAS-Procedures/simulation-from-negative-binomail-distribution/m-p/371650#M65142</link>
      <description>&lt;PRE&gt; It looks good.  
Value/DF is near  1 .

&lt;/PRE&gt;</description>
      <pubDate>Thu, 29 Jun 2017 12:29:37 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Procedures/simulation-from-negative-binomail-distribution/m-p/371650#M65142</guid>
      <dc:creator>Ksharp</dc:creator>
      <dc:date>2017-06-29T12:29:37Z</dc:date>
    </item>
  </channel>
</rss>

