On Sep 4, 2010, at 4:18 PM, Sally Luo wrote:

Hi R users,

I am using the optim funciton to maximize a log likelihood function. My
code is as follows:

p<-optim(c(-0.2392925,0.4653128,-0.8332286, 0.0657, -0.0031, -0.00245,
3.366, 0.5885, -0.00008,
0.0786,-0.00292,-0.00081, 3.266, -0.3632, -0.000049, 0.1856,
0.00394, -0.00193, -0.889, 0.5379, -0.000063,
0.213, 0.00338, -0.00026, -0.8912, -0.3023, -0.000056), f, method
="BFGS", hessian =TRUE, y=y,X=X,W=W)
After I ran the code, I got the following results:
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
p
$par
[1] 2.235834e-02 1.282826e-01 -3.786014e-01 7.422526e-02 3.037931e-02
-2.570156e-03  3.365872e+00  2.618893e-01 -1.987859e-06
[10] 7.970083e-02 2.878574e-03 -1.391019e-03 3.265966e+00 -4.153697e-01
-3.185684e-03  1.833200e-01 -7.247683e-03 -3.156813e-03
[19] -8.889219e-01 6.208612e-01 2.678643e-04 2.183787e-01 2.715062e-02
2.943905e-04 -8.913260e-01 -5.100482e-01 -3.477559e-04

$value
[1] -932.1423

$counts
function gradient
   1439      100

$convergence
[1] 1
$message
NULL

$hessian ( I omitted the approximation results for the hessian here to save
space)
~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The error code 1 for convergence shown above means that the iteration limit maxit had been reached. How can I fix this problem and achieve convergence for my optimization problem? Can I increase the number of maxit so that
convergence might occur?

I am wondering how you expect us to guess at the answer? You are the one who know what "f" is and you are the one who has the option of increasing maxit. If the question is "how" to increase maxit, then the answer is perhaps as easy as:

?optim

--

David Winsemius, MD
West Hartford, CT

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

Reply via email to