[R] rgamma question

Icabalceta, Jorge L. Icabalceta_j at wlf.state.la.us
Fri Feb 6 22:07:07 CET 2004


Sorry to bother you. I am sort of confused with the random number generation
from a gamma distribution. For some reason, if a variable X~gamma(shape,
scale)I have been told that the mean mu can be eithe mu=shape/scale or
mu=shape*scale. Why is that so? This is making me have doubt about the
random generation I am using:

1.- The first variable I have is the precision (h) (the inverse of the
variance)distributed as:
h~gamma((T-2)/2, SSE/2) where T is the number of observations and SSE is the
sum of square errors. How do I draw random number in R with this
information. How do I plug this into 
rgamma(n,shape,scale)?

2.- The second variable is L^-1 ~ gamma(T+1, vi-ln(r*)^-1) (please, don't
mind my no explanation for the terms used in the shape and scale
parameters). Again, How do I plug this into 
rgamma(n,shape,scale)?

3.- I am having a problem putting the results of each iteration from for(i
1:11000) into samp. For some reason I get 10000 identical values for each
column. What am I doing wrong? To see what the problem is you can try to run
the program. Attached is the data I am using, the program with  comments and
without them.

I appreciate your help.
Jorge

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: trans3_1_4g1.txt
Url: https://stat.ethz.ch/pipermail/r-help/attachments/20040206/e8b0538d/trans3_1_4g1.txt
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: stoch_fron.txt
Url: https://stat.ethz.ch/pipermail/r-help/attachments/20040206/e8b0538d/stoch_fron.txt
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: stoch_fron-c.txt
Url: https://stat.ethz.ch/pipermail/r-help/attachments/20040206/e8b0538d/stoch_fron-c.txt


More information about the R-help mailing list