I am new to R and I have been struggling on this for a while. I have a set of 611 data points, and I am trying to estimate its parameters (using MLE) to see if the data comes from a gamma distribution. I would then like to eventually plug the parameters found into a gamma model to then generate a density plot. So far, I have

     fitdistr(fireloss, "gamma")
     shape           rate    
     2.861599e+00   1.963065e-03 
     (1.116362e-01) (7.202933e-05)

I am unsure how to interpret the output. How would these parameters be plugged into a gamma model to generate a density plot? Thanks for the help!


The output gives you the shape and rate parameter of the gamma distribution; you can find on Wikipedia the formula for the shape-rate parametrization.

To plot the probability density function you can just plug the values you obtained in the dgamma function. (I have also generated some data for adding them in the plot as histogram).

shape <- 2.861599e+00  # these are your estimated parameters 
rate <- 1.963065e-03 

y <- rgamma(611, shape = shape, rate = rate) # some random data
x <- seq(0, 6000, length.out=300)

hist(y, breaks = 30, freq = F)
lines(x, dgamma(x, shape = shape, rate = rate), type = "l", col = "blue", lwd = 2)

Histogram with fit Gamma PDF Overlayed


Not the answer you're looking for? Browse other questions tagged or ask your own question.