Re: [R] A Question About Inverse Gamma

From: David Scott <d.scott_at_auckland.ac.nz>
Date: Fri 22 Jul 2005 - 12:36:45 EST

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

>
>
> pantd@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@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@auckland.ac.nz


Graduate Officer, Department of Statistics



R-help@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 Received on Fri Jul 22 12:41:45 2005

This archive was generated by hypermail 2.1.8 : Fri 03 Mar 2006 - 03:33:55 EST