Last active
May 29, 2018 20:05
-
-
Save gatoravi/b23db7deca3ef3b9ce3b63fc746ee988 to your computer and use it in GitHub Desktop.
Estimate parameters of a negative binomial distribution using method of moments
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
> counts <- rnbinom(1000, size = 10, p = 0.1) | |
> mu <- mean(counts) | |
> p <- mu/var(counts) | |
> r <- mu ^ 2/(var(counts) - mu) | |
> hist(counts, freq = F) | |
> curve(dnbinom(x, size = r, prob = p), from = 0, to = max(counts), n = max(counts) + 1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Refer to this link