Have you considered "fitdistr"? The documentation says that the second argument is "Either a character string or a function returning a density evaluated at its first argument." It should be easy enough to write something like the following:

dweibull.trunc <-
function(x, shape, scale=1, trunc.=Inf, log=FALSE){
ln.dens <- (dweibull(x, shape, scale, log=TRUE)
-pweibull(trunc., shape, scale = 1, lower.tail = TRUE, log.p = TRUE))
if(any(oops <- (x>trunc.)))
ln.dens[oops] <- (-Inf) if(log)ln.dens else exp(ln.dens)
}


x <- rweibull(100, 1)
range(x)
x4 <- x[x<=4]
fitdistr(x4, dweibull.trunc, start=list(shape=1, scale=1), trunc=4)

If you want to estimate the truncation point, that will be a more difficult problem. For that, I suggest you compute the max of your data and parameterize the truncated density with a parameter like "log.trunc.over.max" so "trunc." in the above example is computed as (max+exp(log.trunc.over.max)).

hope this helps. spencer graves

Piyush Sharma wrote:

Hi,
 I have recently started working with R and am not really fluent in it. I
am plotting a few graphs using the qqplot function. Is there a method for
fitting a theoretical distribution (e.g Weibull) with truncated tails in R?

Thanks for any help!
Piyush

______________________________________________
[EMAIL PROTECTED] mailing list
https://www.stat.math.ethz.ch/mailman/listinfo/r-help



______________________________________________ [EMAIL PROTECTED] mailing list https://www.stat.math.ethz.ch/mailman/listinfo/r-help

Reply via email to