[R] question on optim() fn.

Ravi Varadhan rvaradhan at jhmi.edu
Wed Oct 20 15:44:30 CEST 2010


Hi,

You are doing the right thing by being concerned about the warning messages.
The warning message of `NaN' usually arises due to illegal arithmetic
operations (in the real number field) such as logarithm or square root of a
negative number.  This could happen during the intermediate stages of an
iterative procedure. If you do not like these warnings, or are concerned
about the solutions, you should try and set bounds on the parameters based
on your knowledge about the statistical model.  Then you would use a
box-constrained optimization algorithm.  If you have more complicated
constraints, you may need more specialized optimization algorithms.

It is hard to tell whether your solution is valid or not without seeing your
model and the output from optim.  If your convergence indicator is 0, this
usually (but not necessarily) means that you have a valid solution, although
I would still check the first and second order KKT optimality conditions.

You can also use `optimx' package, which provides a test of KKT conditions,
and also allows the use of other optimizers in R.   

Ravi.

-----Original Message-----
From: r-help-bounces at r-project.org [mailto:r-help-bounces at r-project.org] On
Behalf Of sharkoil
Sent: Tuesday, October 19, 2010 11:55 PM
To: r-help at r-project.org
Subject: [R] question on optim() fn.


i am trying to use optim() fn in R to estimate mle of my pdf. even though I
am able to get the results, but there are always warning message, which says
that NaN produced.  I am not very sure if I should ignore these warning
message since I have got solution without error message. 
I am wondering if these message is an indicator of bad mle. 
How I can debug to get rid of these warning message?

thanks a lot.
-- 
View this message in context:
http://r.789695.n4.nabble.com/question-on-optim-fn-tp3003217p3003217.html
Sent from the R help mailing list archive at Nabble.com.

______________________________________________
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.



More information about the R-help mailing list