[R] Plot gamma distribution with relative frequency histogram
dila radi
dilaradi21 at gmail.com
Fri Dec 5 03:55:15 CET 2014
Dear R users,
I am looking to fit a gamma curve onto a histogram of the data.
Consider dt1 as my data:
c(203.9, 91.5, 24.5, 34.5, 164, 144, 160.5, 195, 191.5, 189,
133, 110.5, 155, 80.5, 250.5, 116, 145, 118.5, 406, 183.5, 142.5,
197, 367, 134, 153.5)
I am using this code in R
x<-dt1
h<-hist(x,breaks=seq(0,500,25),col=rgb(0,0,1), plot=F)
h$counts <- h$counts / sum(h$counts)
plot(h, freq=TRUE, ylab="Relative Frequency", xlab="Rainfall (mm)",
main = 'Histogram KBU-ML Gamma Disribution')
est <- fitdistr(dt1,"gamma")$estimate
curve(dgamma(x, rate=0.02220921, shape=3.63421746),from=0, to=500,
main="Gamma distribution", add = T, col = "red")
but the gamma fit is not fitted onto histogram as much as it supposed to
be. How should I overcome this?
Thank you in advanced.
Dila
[[alternative HTML version deleted]]
More information about the R-help
mailing list