[R] Fitting weibull, exponential and lognormal distributions to left-truncated data.
Prof Brian Ripley
ripley at stats.ox.ac.uk
Tue Oct 7 13:24:54 CEST 2008
On Tue, 7 Oct 2008, Richard.Cotton at hsl.gov.uk wrote:
>>> I have several datasets, all left-truncated at x=1, that I am
> attempting
>>> to fit distributions to (lognormal, weibull and exponential). I had
>>> been using fitdistr in the MASS package as follows:
>
>> A possible solution is to use the survreg() in the survival package
>> without specifying the covariates, i.e.
>>
>> library(survival)
>> survreg(Surv(..)~1, dist="weibull")
>>
>> where Surv(..) accepts information about "times", censoring/truncation
>> variables and dist allows to specify alternative distributions.
>> See ?Surv e ?survreg
>
> The survival package is mostly targeted at right-censored data. The NADA
> package provides wrappers for many of the survival routines so they work
> with left-censored data.
Left-censoring and left-truncation are not the same thing. With
left-censoring you see that you had observations < 1, and with
left-truncation you do not (at least how the terms are usually applied:
occasionally the meanings are reversed).
For left-truncation it is relatively easy, e.g.
ltwei <- function(x, shape, scale = 1, log = FALSE)
dweibull(x, shape, scale, log)/pweibull(1, shape, scale, lower=FALSE)
and use this in fitdistr.
--
Brian D. Ripley, ripley at 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
More information about the R-help
mailing list