[R] Fitting a Weibull/NaNs

Eric Rescorla ekr at rtfm.com
Mon Oct 20 02:56:15 CEST 2003


Spencer Graves <spencer.graves at pdf.com> writes:
>       I have not used "nlm", but that happens routinely with function
>       minimizers trying to test negative values for one or more
>       component of x.  My standard approach to something like this is
>       to parameterize "llfunc" in terms of log(shape) and log(scale),
>       as follows: llfunc <- function (x) {
>       -sum(dweibull(AM,shape=exp(x[1]),scale=exp(x[2]), log=TRUE))}
>
>       Have you tried this?  If no, I suspect the warnings will
>       disappear when you try this.

This works. I've got some more questions, though:

(1) Does it introduce bias to work with the logs like this?

(2) My original data set had zero values. I added .5 experimentally,
    which is how I got to this data set. This procedure doesn't work
    on the original data set.

    Instead I get (with the numbers below being the values
    that caused problems):

[1] 0.41 3.70 1.00
[1] 0.41 3.70 1.00
[1] 0.410001 3.700000 1.000000
[1] 0.410000 3.700004 1.000000
[1] 0.410000 3.700000 1.000001
Warning messages: 
1: NA/Inf replaced by maximum positive value 
2: NA/Inf replaced by maximum positive value 
3: NA/Inf replaced by maximum positive value 
4: NA/Inf replaced by maximum positive value 

Thanks,
-Ekr

-- 
[Eric Rescorla                                   ekr at rtfm.com]
                http://www.rtfm.com/




More information about the R-help mailing list