[R] optim and nlm error to estimate a matrix

Ji Young Kim jykim4 at illinois.edu
Mon Oct 13 20:21:07 CEST 2008

Dear R users,

I'm trying to estimate the matrix of regression parameters.
I need to do it numerically, so I used optim and nls.
I got the initial parameter estimates from least squares, and input them into those functions.

But when I run the optim function, it stops in 30 seconds and shows 'convergence=1'. 
And if I use the nlm function, then it runs for a while, and finally stops with the code=4.

Both of these error codes mean  "iteration limit exceeded".
Since the maxit for optim is 500 for Nelder-Mead by default, I increased the maxit to 1000, but it still gives me the same error code.

Can anyone tell me how I can fix the problem?

I defined an objective function in the following way :

## Objective function to be minimized
    obj1=rep(0,n) ; beta.m=matrix(beta.v,p,sdf)
    for (i in 1:n){

I tried to find a minimizer from functions below :
where ini.beta is the initial parameters obtained from least squares estimation.

The most weird thing to me is that result1 gives exactly the same values as the initial values, while result2 gives a little different values from the initial values, and it gives a smaller value of obj, which means nlm moved the initial value a little toward the true minimizer.

At first, I thought I put too good initial values, and therefore the algorithm didn't need to move too much, but even if I just put a matrix of 1's, it still stops with the same error codes. 

*** This is my first time to post a question. I apologize if I didn't explain enough. I would be very happy to listen to anyone's suggestions.
Thanks for your time!!

Ji Young

More information about the R-help mailing list