-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 [EMAIL PROTECTED] wrote: | I am trying to fit a set of data to a Weibull distribution. Because the implementation requires that I put the data in the range of 0 < x < 1 I have a "normailze" function: | | normalize <- function(x) { | y <- (x-min(x)) / (max(x) - min(x)) | y = y + 0.5 * (y == 0) -0.5 * (y == 1) | return (y) | } | | So the output to this normalize function is: | | normalize(c(93,34,16,120,53,75)) | [1] 0.7403846 0.1730769 0.5000000 0.5000000 0.3557692 0.5673077 | | If I calculate the model parameters by hand (basically through a line fit) I get: | | $shape | [1] 2.022953 | $scale | [1] 0.5528019 | $r | [1] 0.9661575 | | When I run fitdistr I get: | | fitdistr(normalize(c(93,34,16,120,53,75)), "weibull") | shape scale | 3.02746335 0.52969005 | (1.01520182) (0.07482737) | Warning messages: | 1: In dweibull(x, shape, scale, log) : NaNs produced | 2: In dweibull(x, shape, scale, log) : NaNs produced | | My first concern is the warnings. Why are the NaNs produced? | Next is that values produced. I have used my "manual" method | for some time now and I think it produces an accurate fit. | The numbers produced by fitdistr are of the same order but | they are still different than I would expect. So the combination of | the warnings and the questionable response doesn't inspire | my confidence. Am I doing something wrong?
~ I don't think you're doing anything wrong. The warnings are about the optimizer within fitdistr trying a few negative values for shape or scale -- one way to double-check this is: n = normalize(c(93,34,16,120,53,75)) mle2(n~dweibull(shape=sh,scale=sc),start=list(sh=0.5,sc=10), ~ method="L-BFGS-B",lower=c(0.002,0.002)) ~ which runs a bounded search. ~ I can't really say anything about the discrepancy between fitdistr/bbmle and your manual search without knowing more about your method ... ~ Ben -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org iD8DBQFInKexc5UpGjwzenMRAsXYAJ9vJmsuZKfYdqo9cgxZtcp6kbY/0wCffTFW vlJlUdLusMHcuO1iipqaMLc= =rbUl -----END PGP SIGNATURE----- ______________________________________________ R-help@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.