[R] Distribution fitting with binned data

David Winsemius dwinsemius at comcast.net
Fri Dec 4 20:09:16 CET 2009


On Dec 4, 2009, at 2:04 PM, Bradley W. Settlemyer wrote:

> Hello
>
>  I need to fit a distribution to a histogram data set.  I have read  
> Ricci's guide to distribution fitting, and am ready to begin  
> experimenting with the techniques it mentions, but I am uncertain  
> how to get my data in the format he uses.
>
>  My problem is that my data is binned.  So for example my data is in  
> the following format
>
> #lb  ub  count
>  0   1  4
>  1   2  7
>  2   3  2

? rep

 > rep(c(1,2,3), c(4,7,2))
  [1] 1 1 1 1 2 2 2 2 2 2 2 3 3


>
> Indicating that I have 4 observations between 0 and 1, 7 obs between  
> 1 and 2, and 2 obs between 2 and 3.  I assume it should be simple to  
> somehow transform the dataset to a vector such as:
>
> 1
> 1
> 1
> 1
> 2
> 2
> 2
> 2
> 2
> 2
> 3
> 3
>
> But I don't know how to do that in R.  I have a decent amount of  
> datasets I will want to perform this distribution fitting analysis,  
> so if there is a better way, I'm game to learn about it.  So any  
> help is welcome.
>
> Cheers,
> Brad
>
> ______________________________________________
> R-help at r-project.org 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.

David Winsemius, MD
Heritage Laboratories
West Hartford, CT




More information about the R-help mailing list