xiaodong jin
2002-Oct-16 20:55 UTC
[R] how to overlay the histogram with fitted gamma density plot (emergent!!)
For a real data column X value ranged between (56.4521,32317.9) with missing values, I need to overlay 2 plots: histogram & fitted gamma density. I use following to generate histogram. xbk_seq(50,33000,by=100) hist(x,breaks=xbk) But I don't know how to get "fitted gamma density"? In SAS proc capability, I got Shape=2.59, Scale=3481). But when I do plot(dgamma(x, shape=2.59, rate=1,scale=3481)), it gives me a flat densed line close to 0, which does not look correct. Would anybody help me on this? Thanks! Shelton --------------------------------- Faith Hill - Exclusive Performances, Videos, & more faith.yahoo.com -------------- next part -------------- An HTML attachment was scrubbed... URL: https://stat.ethz.ch/pipermail/r-help/attachments/20021016/0757ad80/attachment.html
Peter Dalgaard BSA
2002-Oct-16 21:28 UTC
[R] how to overlay the histogram with fitted gamma density plot (emergent!!)
xiaodong jin <jin_xiaodong at yahoo.com> writes:> For a real data column X value ranged between (56.4521,32317.9) with missing values, I need to overlay 2 plots: histogram & fitted gamma density. > > I use following to generate histogram. > > xbk_seq(50,33000,by=100) > > hist(x,breaks=xbk) > > But I don't know how to get "fitted gamma density"? > > In SAS proc capability, I got Shape=2.59, Scale=3481). > > But when I do > > plot(dgamma(x, shape=2.59, rate=1,scale=3481)), it gives me a flat densed line close to 0, which does not look correct. > > Would anybody help me on this?First of all, you need to make sure that your histogram is on "density scale" (i.e. not raw bin counts) by using prob=TRUE. Then comes the issue of checking that SAS and R agree on the parametrization of the gamma distribution. The MASS library has fitdistr() which might be helpful. -- 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 _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._