This is both a specific question and a general one. First, I am running 'fitdistr' from library(MASS) and I get the following: Error in fitdistr(templist, "weibull") : optimization failed What is the cause of the error? How can I tell? Can I just catch this error, report it and move to the next set of data (eat the exception)? Thank you. Kevin
Determining cause of error?
4 messages · rkevinburton at charter.net, Charles C. Berry, Henrik Bengtsson
On Wed, 13 Aug 2008, rkevinburton at charter.net wrote:
This is both a specific question and a general one. First, I am running 'fitdistr' from library(MASS) and I get the following: Error in fitdistr(templist, "weibull") : optimization failed What is the cause of the error? How can I tell? Can I just catch this error, report it and move to the next set of data (eat the exception)?
You can use try() or tryCatch() to both allow further calculation and to save the current input to fitdistr() for further study. Alternatively, you can set options(error=recover) - see ?recover - and see where the error comes from. HTH, Chuck
Thank you. Kevin
______________________________________________ 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.
Charles C. Berry (858) 534-2098
Dept of Family/Preventive Medicine
E mailto:cberry at tajo.ucsd.edu UC San Diego
http://famprevmed.ucsd.edu/faculty/cberry/ La Jolla, San Diego 92093-0901
See ?traceback /Henrik
On Wed, Aug 13, 2008 at 7:33 PM, <rkevinburton at charter.net> wrote:
This is both a specific question and a general one. First, I am running 'fitdistr' from library(MASS) and I get the following: Error in fitdistr(templist, "weibull") : optimization failed What is the cause of the error? How can I tell? Can I just catch this error, report it and move to the next set of data (eat the exception)? Thank you. Kevin
______________________________________________ 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.
Now this is really specific. I think the cause of the error is a small sample size. For example. The following both fail:
fit <- fitdistr(c(120), "weibull")
fit <- fitdistr(jiitter(c(120,120), amount=0.5), "weibull")
As it is hard for me to control the sample size or the proximity of data values in the sample I was wondering how I can tell what the error modes for 'fitdistr' are? If I knew that 'fitdistr' will error out with a sample of of one or a sample of two values that are close then I could put a conditional statement an make a "reasonable" guess (something that I would expect 'fitdistr' to do). For example I could"
if(length(templist) > 1)
{
fit <- fitdistr(templist, "weibull")
}
The problem is that I don't know all the possible error conditions. I know that having a sample size of 1 is bad and a sample of two "close" values is bad. Are there others?
Thank you.
Kevin
---- Henrik Bengtsson <hb at stat.berkeley.edu> wrote:
See ?traceback /Henrik On Wed, Aug 13, 2008 at 7:33 PM, <rkevinburton at charter.net> wrote:
This is both a specific question and a general one. First, I am running 'fitdistr' from library(MASS) and I get the following: Error in fitdistr(templist, "weibull") : optimization failed What is the cause of the error? How can I tell? Can I just catch this error, report it and move to the next set of data (eat the exception)? Thank you. Kevin
______________________________________________ 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.