[R] Fit continuous distribution to truncated empirical values
David Winsemius
dwinsemius at comcast.net
Fri Nov 4 19:56:48 CET 2011
On Nov 3, 2011, at 7:54 AM, Michele Mazzucco wrote:
> Hi all,
>
> I am trying to fit a distribution to some data about survival times.
> I am interested only in a specific interval, e.g., while the data
> lies in the interval (0,...., 600), I want the best for the interval
> (0,..., 24).
>
> I have tried both fitdistr (MASS package) and fitdist (from the
> fitdistrplus package), but I could not get them working, e.g.
>
> fitdistr(left, "weibull", upper=24)
> Error in optim(x = c(529L, 528L, 527L, 526L, 525L, 524L, 523L, 522L,
> 521L, :
> L-BFGS-B needs finite values of 'fn'
> In addition: Warning message:
> In dweibull(x, shape, scale, log) : NaNs produced
>
> Am I doing something wrong?
You didn't supply data to test, but shouldn't you supply a lower
bound if you want to fit "weibull"? It is, after all, bounded at 0.
> left <- c(529L, 528L, 527L, 526L, 525L, 524L, 523L, 522L, 521L,
50*runif(100))
> fitdistr(left, "weibull", upper=24)
Error in optim(x = c(529, 528, 527, 526, 525, 524, 523, 522, 521,
18.3964251773432, :
L-BFGS-B needs finite values of 'fn'
In addition: Warning message:
In dweibull(x, shape, scale, log) : NaNs produced
> fitdistr(left, "weibull", upper=24, lower=0.5)
shape scale
0.58195013 24.00000000
( 0.04046087) ( 3.38621367)
>
>
> Thanks,
> Michele
>
>
> p.s. I have seen similar posts, e.g., http://tolstoy.newcastle.edu.au/R/help/05/02/11558.html
> , but I am not sure whether I can apply the same approach here.
> ______________________________________________
> 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