[R] how to overlay the histogram with fitted gamma density plot (emergent!!)
Peter Dalgaard BSA
p.dalgaard at biostat.ku.dk
Wed Oct 16 23:28:24 CEST 2002
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.
> 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
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
More information about the R-help