PDA

View Full Version : data simulation help



manoa
08-05-2011, 08:48 PM
Hi all,

How do I generate count data from a gamma distribution, preferably using SAS?

For example, I assume that frequency of persons born in each month during 1992 follows a Gamma distribution. So the data would looks like this:

month_born
1
1
12
12
3
3
3
...

So if you do a histogram on this, it would look like a gamma dist.
(I know this may not be realistic, but just assume it is!)

How do I generate my data, so the data come from a Gamma? Thanks.

jpkelley
08-05-2011, 09:13 PM
Do you mean that you need to determine a best fit (Gamma, etc.) to these data and then generate a histogram of simulated data from the best fit distribution? Not sure about SAS, but the fitdistr() function in package MASS will help will the fitting. Then, to generate the Gamma, you could use the rgamma() function. But, it seems like you really need to go from Gamma to Poisson since you're dealing with count data. I suppose you could generate a large Gamma population and then do some rounding in order to get the large count population (this would likely change your perfect Gamma fit). I would just see if a Poisson fit your raw data compared to other distributions, then generate a large Poisson-distributed population (counts).

This might not have answered your question specifically, but hopefully it would get you started. If this didn't answer your question, feel free to yell!

Dason
08-05-2011, 09:45 PM
Note: jpkelley was talking about R (http://cran.r-project.org/).