[R] question on optim() fn.

Ravi Varadhan rvaradhan at jhmi.edu
Thu Oct 21 16:36:08 CEST 2010


As I said before, you get NaNs whenever the iterates are such that they are mathematically infeasible.  This could very much depend on the starting value for the optimizer, as you have observed, because the trajectories of the optimizer can be widely different when started from diffrent parameter values.

KKT stands for Karash-Kuhn-Tucker conditions.  They provide the standard, necessary conditions for a parameter vector to be a local optimum in smooth problems.  The first order conditions relates to the stationarity of the objective function and can be tested using its gradient  (or the augmented Lagrangian in the case of constrained optimization), and the second order condition pertains to the curvature of the objective function (or the augmented Lagrangian).   In convex optimization, KKT conditions are also sufficient.

optim() does not test for the KKT conditions.  You can use optimx() to do this, although the results of the tests of first and second order conditions are sensitive to scaling of parameters and objective function.

Ravi.

____________________________________________________________________

Ravi Varadhan, Ph.D.
Assistant Professor,
Division of Geriatric Medicine and Gerontology
School of Medicine
Johns Hopkins University

Ph. (410) 502-2619
email: rvaradhan at jhmi.edu


----- Original Message -----
From: sharkoil <whitewhale2006 at gmail.com>
Date: Thursday, October 21, 2010 1:09 am
Subject: Re: [R] question on optim() fn.
To: r-help at r-project.org


>  Hi Ravi,
>  
>  Thanks a lot for your informations. I think you are right. Without the
>  constraints of the parameters, it's easy to get the "NaN Produced" warning
>  message. The pdfs I worked on are Burr, Lognormal and Inverse Gaussian
>  distributions. Lognormal distribution is ok, but I always have warning
>  message to get mle for Burr and Inverse Gaussian. Also I found out that
>  different initial values make difference. Some will get the valid MLE
>  without warning message, some will have warning message. Don't why! Probably
>  I have to try optimx() function. By the way, what is KKT test? Does optim()
>  function have this output
>  
>  I did get the MLE with convergence being 0. With your tips, I will assume
>  that I have got the valid MLE even though I had the warning message. 
> 
>  
>  Also I tried to use proc nlmixed procedure in sas to estimate the 
> MlE. It
>  seems the optim() function and proc nlmixed give me the similar MLE. 
> 
>  
>  Regards
>  -- 
>  View this message in context: 
>  Sent from the R help mailing list archive at Nabble.com.
>  
>  ______________________________________________
>  R-help at r-project.org mailing list
>  
>  PLEASE do read the posting guide 
>  and provide commented, minimal, self-contained, reproducible code.



More information about the R-help mailing list