turn on suggestions

Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.

Showing results for

Find a Community

- Home
- /
- SAS Programming
- /
- Base SAS Programming
- /
- Random sample and coefficient of dispersion

Topic Options

- RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

08-23-2014 11:25 AM

Hello,

I would like to generate a random sample (= 30 obervations) following a negative binomial distribution with expectation = 3 and a** coefficient of dispersion (expectation / variance) = 1.2**.

sample data;

do i = 1 to 30;

nb_asif = 3 + RAND ('NEGBINOMIAL', ?,?);

output;

end;

run;

How determine my coefficient of dispersion into data step?

Thanks for help.

Accepted Solutions

Solution

08-23-2014
06:49 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to jonathanch

08-23-2014 06:49 PM

data sample;

do i = 1 to 30;

nb_asif = 3 + RAND ('NEGBINOMIAL', 0.8333,15);

output;

end;

run;

All Replies

Solution

08-23-2014
06:49 PM

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to jonathanch

08-23-2014 06:49 PM

data sample;

do i = 1 to 30;

nb_asif = 3 + RAND ('NEGBINOMIAL', 0.8333,15);

output;

end;

run;

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to stat_sas

08-25-2014 06:09 AM

I was wrong! it's variance/expectation to calculate coefficient of dispersion.

With your code it doesn't work, it's not equal to 1.2

data echantillon;

do i=1 to 30;

nb_asif=3+RAND('NEGBINOMIAL',0.8333,15) ;

output;

end;

run;

proc univariate data=echantillon;

var nb_asif;

output out=dispersion std=volatite var=variance mean=moyenne skewness=skewness kurtosis=kurtosis;

run;

data dispersion1;

set dispersion;

DI=variance/moyenne;

run;

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to jonathanch

08-25-2014 09:57 AM

Yes, as per formulation p was going to be greater than one. After making a correction found p=0.8333 and k=15. If you exclude 3 from your equation then you will get a close approximation as sample size increases.

nb_asif=RAND('NEGBINOMIAL',0.8333,15) ;

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to stat_sas

08-25-2014 11:47 AM

Sorry for my ignorance but I don't understand...:smileyconfused:

How did you make a correction? p=1/1.2?

And I don't manage how you found the dispersion coefficient = 1.2 after generate.

Thanks.

- Mark as New
- Bookmark
- Subscribe
- RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content

Posted in reply to jonathanch

08-25-2014 11:56 AM

Please consult properties of negative binomial distribution to understand this in a better way.