I am using base sas 9.4. Now I am working on Simulating data.
After I fitted data to negative binomial distribution using the following code ;
proc countreg data=claim;
         model y = / dist=negbin;
         output out=exp_nb prob=prob_nb;
         freq freq;
         run;
     proc format;
         value yfmt     
           7-high = ">=7";
         run;
      
      proc means sum nway data=exp_nb;
         class y;
         var prob_nb;
         format y yfmt.;
         output out=exp_nb sum=_testp_;
         run;
      data exp_nb;
         set exp_nb;
         sumexp + _testp_;
         sumtolast = lag(sumexp);
         if y=7 then _testp_ = 1 - sumtolast;
         run;
      proc freq data=claims;
         table y / chisq(testp=exp_nb df=-2 lrchisq);
         format y yfmt.;
         weight freq;
         run;
Then I got only p-value from fitting this data.
Now I want to simulate data from negative binomial distribution.
How can I do that ? please help
(version of sas program do not have Proc iml procedure)
You can simulate data from a negative binomial distribution using the RAND function like this
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;
Adjust p and k to your liking. The documentation is here
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001466748.htm
You can simulate data from a negative binomial distribution using the RAND function like this
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;
Adjust p and k to your liking. The documentation is here
http://support.sas.com/documentation/cdl/en/lrdict/64316/HTML/default/viewer.htm#a001466748.htm
could you please tell me that how can I know p of this data from fitting the distribution.
because when 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.
Ha. Here is.
http://blogs.sas.com/content/iml/2012/04/04/fitting-a-poisson-distribution-to-data-in-sas.html
proc genmod data=MyData;
   model N = / dist=negbin;
   output out=Fit p=lambda;
run;
I am sorry to bother you. But after following your suggestion I got the attached output.
How can I know this model fits the data or not.
It looks good. Value/DF is near 1 .
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.