Inverse gamma

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Inverse gamma

Patrick Wang-2
Hi, All:

assume I need to generate X from inverse gamma with parameter (k, beta).

should I generate from Y from gamma(-k, beta),

then take X=1/Y?

Thanks
pat

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Reply | Threaded
Open this post in threaded view
|

Re: Inverse gamma

ALBERTO VIEIRA FERREIRA MONTEIRO
Patrick Wang wrote:
>
> assume I need to generate X from inverse gamma with parameter (k,
>  beta).
>
> should I generate from Y from gamma(-k, beta),
>
> then take X=1/Y?
>
Check the Borg of All Wisdom...
http://en.wikipedia.org/wiki/Inverse-gamma_distribution

Generate Y from gamma(k, 1/beta) (using...
  rgamma(n = number.of.points, shape = k, scale = 1/beta)
... or ...
  rgamma(n = number.of.points, shape = k, rate = beta)
) and take X = 1/Y

(unless your beta is not the rate parameter...)

Alberto Monteiro

______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.