Re: [R] Help on simple problem with optim

2010-09-13 Thread Cristian Montes
, Cristián Montes. -Mensaje original- De: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] En nombre de Zhang,Yanwei Enviado el: Jueves, 09 de Septiembre de 2010 02:54 p.m. Para: r-help@r-project.org Asunto: [R] Help on simple problem with optim Dear all, I ran into problems

Re: [R] Help on simple problem with optim

2010-09-10 Thread Berend Hasselman
It is indeed a negative value for sigma that causes the issue. You can check this by inserting this line if(sigma = 0 ) cat(Negative sigma=,sigma,\n) after the line mu - x %*% beta in function llk.mar Negative values for sigma can be avoided with the use of a transformation

[R] Help on simple problem with optim

2010-09-09 Thread Zhang,Yanwei
Dear all, I ran into problems with the function optim when I tried to do an mle estimation of a simple lognormal regression. Some warning message poped up saying NANs have been produced in the optimization process. But I could not figure out which part of my code has caused this. I wonder if

Re: [R] Help on simple problem with optim

2010-09-09 Thread Thomas Stewart
This is only a guess because I don't have your data: sigma is must be positive in the dnorm function. My guess is that optim may attempt an iteration with a negative sigma. You may want to see help(optim) for dealing with this constraint. Specifically see the lower argument. If you specify

Re: [R] Help on simple problem with optim

2010-09-09 Thread Peng, C
Yanwei!!! Have you tried to write the likelihood function using log-normal directly? if you haven't so, you may want to check ?rlnorm -- View this message in context: http://r.789695.n4.nabble.com/Help-on-simple-problem-with-optim-tp2533420p2533487.html Sent from the R help

Re: [R] Help on simple problem with optim

2010-09-09 Thread William Dunlap
- From: r-help-boun...@r-project.org [mailto:r-help-boun...@r-project.org] On Behalf Of Zhang,Yanwei Sent: Thursday, September 09, 2010 11:54 AM To: r-help@r-project.org Subject: [R] Help on simple problem with optim Dear all, I ran into problems with the function optim when I tried