Re: [R] Fitting Distributions Directly From a Histogram

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Mon 12 Jun 2006 - 21:55:53 EST

On Mon, 12 Jun 2006, Lorenzo Isella wrote:

> Dear All,
>
> A simple question: packages like fitdistr should be ideal to analyze
> samples of data taken from a univariate distribution, but what if
> rather than the raw data of the observations you are given directly
> and only a histogram?

(It is unusual for the actual data not to be available in real problems.)

> I was thinking about generating artificially a set of data
> corresponding to the counts binned in the histogram, but this sounds
> too cumbersome.

And that is not in any case a correct approach, since the mle from binned data is not the same as the mle from any dataset corresponding to the binned counts.

You could use mle (package stats4) to estimate parameters from the likelihood of the grouped data.

> Another question is the following: fitdistr provides the value of the
> log-likely hood function, but what if I want e.g. a chi square test to
> get some insight on the goodness of the fitting?
> I am sure there must be a way to get it straightforwardly without
> coding it myself.

It is not well-defined, as you need to choose a binning to do a chisq test. Once you have (e.g. via cut and table), chisq.test() will produce the test statistic and refer it to a reference distribution (which will not take any parameter estimation into account).

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
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, UK                Fax:  +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
Received on Mon Jun 12 22:02:31 2006

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Mon 12 Jun 2006 - 22:11:38 EST.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.