Faheem Mitha
2000-Apr-14 16:30 UTC
[R] rgamma with negative shape and scale parameters works?
Dear R people, This is a possibly silly question, but the rgamma function takes the shape and scale arguments and simulates gamma rvs corresponding to those values, right? But the shape and scale parameters have to be positive, right? However, rgamma quite happily returns to me values for negative values of shape and scale, and in some cases returns negative values eg.> rgamma(1, 1, -1)[1] -1.011081> rgamma(1, -1, -1)[1] -1.710464> rgamma(1, -1, 1)[1] 2.058639 What is with this? Is some generalised version of gamma being used or what? Can someone enlighten me? Thanks. Faheem. -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
Peter Dalgaard BSA
2000-Apr-14 16:44 UTC
[R] rgamma with negative shape and scale parameters works?
Faheem Mitha <faheem at email.unc.edu> writes:> Dear R people, > > This is a possibly silly question, but the rgamma function takes the shape > and scale arguments and simulates gamma rvs corresponding to those values, > right? But the shape and scale parameters have to be positive, right? > However, rgamma quite happily returns to me values for negative values of > shape and scale, and in some cases returns negative values eg. > > > rgamma(1, 1, -1) > [1] -1.011081 > > rgamma(1, -1, -1) > [1] -1.710464 > > rgamma(1, -1, 1) > [1] 2.058639Most likely, it is a bug(let). Calculating dgamma(rgamma(... with the same parameters give NaN. -- O__ ---- Peter Dalgaard Blegdamsvej 3 c/ /'_ --- Dept. of Biostatistics 2200 Cph. N (*) \(*) -- University of Copenhagen Denmark Ph: (+45) 35327918 ~~~~~~~~~~ - (p.dalgaard at biostat.ku.dk) FAX: (+45) 35327907 -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html Send "info", "help", or "[un]subscribe" (in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._