There is no built-in function that I know of for fitting a distribution to a frequency table. Note that a theoretically continuous distribution is inappropriate for the table, because the data is discrete. Of course, for sufficiently large N and sufficiently thin meshes this can be ignored.
You can create your own model function using optim or any other optimizer if you know the density that you are interested in. I did it here for gamma distribution (which was a bad assumption for this particular dataset, but no matter what).
The code is reproduced below.
negll <- function(par, x, y) { shape <- par[1] rate <- par[2] mu <- dgamma(x, shape, rate) * sum(y) -2 * sum(dpois(y, mu, log=TRUE)) } optim(c(1, 1), negll, x=seq_along(g$count), y=g$count, method="L-BFGS-B", lower=c(.001, .001)) $par [1] 0.73034879 0.00698288 $value [1] 62983.18 $counts function gradient 32 32 $convergence [1] 0 $message [1] "CONVERGENCE: REL_REDUCTION_OF_F <= FACTR*EPSMCH"
source share