[R] A Question About Inverse Gamma

David Scott d.scott at auckland.ac.nz
Fri Jul 22 04:36:45 CEST 2005


On Thu, 21 Jul 2005, Sundar Dorai-Raj wrote:

>
>
> pantd at unlv.nevada.edu wrote:
>> Hi R users,
>>
>>
>> I am having a little problem finding the the solution to this problem in R:
>>
>> 1. I need to generate normal distribution of sample size 30, mean = 50, sd = 5.
>> 2. From the statistics obtained in step 1, I need to generate the Inverse Gamma
>> distribution.
>>
>> Your views and help will be appreciated.
>>
>> ______________________________________________
>> R-help at stat.math.ethz.ch mailing list
>> https://stat.ethz.ch/mailman/listinfo/r-help
>> PLEASE do read the posting guide! http://www.R-project.org/posting-guide.html
>
> I found rinvgamma in the MCMCpack package. Perhaps that's what you need.
>


I think there is a problem with rinvgamma:

> rinvgamma
function (n, shape, scale = 1)
{
     return(1/rgamma(n, shape, scale))
}
<environment: namespace:MCMCpack>

I know it is not necessarily authoritative but look at wikipedia

http://en.wikipedia.org/wiki/Inverse-gamma_distribution

It seems the one line of the function should be:

return(1/rgamma(n, shape, 1/scale)


Or you could of course throw caution to the winds and write your own 
rinvgamma using rgamma :-)

David Scott




_________________________________________________________________
David Scott	Department of Statistics, Tamaki Campus
 		The University of Auckland, PB 92019
 		Auckland	NEW ZEALAND
Phone: +64 9 373 7599 ext 86830		Fax: +64 9 373 7000
Email:	d.scott at auckland.ac.nz


Graduate Officer, Department of Statistics




More information about the R-help mailing list