Let $X$ have the Negative Binomial distribution with parameters $r$ and $p$. The Negative Binomial distribution is a mixture distribution or compound distribution. That is $X$ is $\text{Poisson}(\lambda)$ where $\lambda$ is randomly chosen from a $\text{Gamma}(r, p/(1-p))$. Use this relation to write an R function for randomly drawing $n$ Negative Binomial random samples. Hint: Use the R functions rpois and rgamma.
Tell me more
×
Cross Validated is a question and answer site for
statisticians, data analysts, data miners and data visualization experts. It's 100% free, no registration required.
|
|
||||
|
The answer is contained in the description of the mixture decomposition of the negative binomial distribution as a Poisson distribution where the parameter is itself random with a Gamma distribution. How much more of a hint do you need? |
|||||||||||||||||||||
|
|
If this is not a homework question, you're probably better off with the |
|||
|
homeworktag to this question. – cardinal Nov 28 '11 at 13:56