Re: [R] ML fit of gamma distribution to grouped data

2006-11-30 Thread Thomas Petzoldt
Dear Augusto,

thank you for your example. Your solutions are the in fact the usual 
methods, but these do not apply to my case because I have grouped data.

The good news is, that the solution of Prof. Brian Ripley works 
perfectly -- of course :-)

Thank you both for your help.

Thomas P.


[EMAIL PROTECTED] wrote:
  Thomas,
 
  The Gamma distr. can be fitted via ML using:
 
  Library(MASS)
  GF - fitdistr(given_data,gamma)
  sh - GF$estimate[1]
  ra - GF$estimate[2]
 
  Fitting via Moments, m:
  var - m[2] - m[1]*m[1]
  sh - m[1]*m[1]/var
  sc - m[1]/var
  ra - 1/sc
 
  G_pdf - dgamma(breaks,shape=sh,rate=ra,scale=1/ra)
 
 
  Hope it helps,
 
  Augusto

[...] original message deleted

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ML fit of gamma distribution to grouped data

2006-11-29 Thread Augusto.Sanabria
Thomas,

The Gamma distr. can be fitted via ML using:

Library(MASS)
GF - fitdistr(given_data,gamma)
sh - GF$estimate[1]
ra - GF$estimate[2]

Fitting via Moments, m:
var - m[2] - m[1]*m[1]
sh - m[1]*m[1]/var
sc - m[1]/var
ra - 1/sc

G_pdf - dgamma(breaks,shape=sh,rate=ra,scale=1/ra)


Hope it helps,

Augusto



Augusto Sanabria. MSc, PhD.
Mathematical Modeller
Risk Research Group
Geospatial  Earth Monitoring Division
Geoscience Australia (www.ga.gov.au)
Cnr. Jerrabomberra Av.  Hindmarsh Dr.
Symonston ACT 2601
Ph. (02) 6249-9155
 
 




-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Thomas Petzoldt
Sent: Tuesday, 28 November 2006 10:26
To: r-help@stat.math.ethz.ch
Subject: [R] ML fit of gamma distribution to grouped data


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)

Any help is highly appreciated

Thomas P.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


[R] ML fit of gamma distribution to grouped data

2006-11-28 Thread Thomas Petzoldt
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)

Any help is highly appreciated

Thomas P.

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Re: [R] ML fit of gamma distribution to grouped data

2006-11-28 Thread Prof Brian Ripley
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)

 Any help is highly appreciated

 Thomas P.

 __
 R-help@stat.math.ethz.ch mailing list
 https://stat.ethz.ch/mailman/listinfo/r-help
 PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
 and provide commented, minimal, self-contained, reproducible code.


-- 
Brian D. Ripley,  [EMAIL PROTECTED]
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel:  +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UKFax:  +44 1865 272595

__
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.