daryl yiu
2007-Sep-04 14:04 UTC
[R] ML fit of pareto and lognormal distributions to grouped data
Dear list members, I have a set of claims data, which are in ranges and the shape of the distribution is relatively different. I have looked through R help threads and found out that an ideal way is suggested for the gamma distribution ML fitting for grouped data. I just wonder if there is any method that works for lognormal or pareto distribution? An example would be: Ranges<-c(0,50,100,150,200,250,300,400,500,750,1000) Claims<-c(452,62,95,88,118,118,261,367,972,982,3024)>From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk> >Date: Tue 28 Nov 2006 - 13:26:11 GMT > > >library(stats4) > >ll <- function(shape, rate) >{ > > z <- pgamma(breaks, shape=shape, rate=rate) > -sum(counts * log(diff(z))) > > >} >mle(ll, start=list(shape=1, rate=1/mean(breaks))) > >looks a plausible fit. > >On Tue, 28 Nov 2006, Thomas Petzoldt wrote: > >> Hello, >> >> we have a set of biological cell-size data, which are only available as >> frequencies of discrete size classes, because of the high effort of >> manual microscopic measurements. >> >> The lengths are approximately gamma distributed, however the shape of >> the distribution is relatively variable between different samples (maybe >> it's a mixture in reality). >> >> Is there any ML fitting (or moment-based) procedure for the gamma >> distribution and grouped data already available in R? >> >> Here is a small example: >> >> breaks <- c(0, 20, 30, 40, 50, 60, 70, 80, 90, 100, 150) >> mids <- c(10, 25, 35, 45, 55, 65, 75, 85, 95, 125) >> counts <- c(87, 5, 2, 2, 1, 1, 0, 0, 1, 1) >>Thank you very much and any assistant is really appreciated! -- Daryl Yiu