Re: [R] rgamma with rate as vector

2008-11-17 Thread Ben Bolker
wcyee wcyeee at gmail.com writes:

 

  [snip]
 
 How does the function rgamma work in the instance with the rate
 specified as a vector of values?  My understanding is that rgamma
 returns m random values from the gamma distribution for a given shape,
 rate.  But I don't understand what the resulting lambda1's mean with
 many rate values.
 

  If there are m rate values, then each of the m random deviates
will be chosen with the corresponding rate parameter.

  Ben Bolker

__
R-help@r-project.org 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.


[R] rgamma with rate as vector

2008-11-15 Thread wcyee
Hi - I have a question about the following code from Bayesian
Computation with R (Jim Albert).

par(mfrow=c(2,2))
m = 500
alphas = c(5, 20, 80, 400)
for (j in 1:4) {
mu = rgamma(m, shape=10, rate=10)
lambda1 = rgamma(m, shape=alphas[j], rate=alphas[j]/mu)
lambda2 = rgamma(m, shape=alphas[j], rate=alphas[j]/mu)
plot(lambda1, lambda2)
title(main=paste('alpha=', alphas[j]))
}


How does the function rgamma work in the instance with the rate
specified as a vector of values?  My understanding is that rgamma
returns m random values from the gamma distribution for a given shape,
rate.  But I don't understand what the resulting lambda1's mean with
many rate values.

Thanks!

__
R-help@r-project.org 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.