[R] error in mle -- user error reported by optim

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Sep 1 09:02:14 CEST 2004


The error is rather in _your_ log-likelihood: you are going to have to try
much harder to avoid underflow/overflow.

Avoiding log(exp(a1*x1+a2*x2)) would be a start.  You might begin to 
appreciate why R's d*** and p*** functions have a `log.p' argument.

Better starting values would help, probably a lot.  Also read about 
scaling problems in ?optim.

On Wed, 1 Sep 2004, Olympio T. Neto wrote:

> Friends
> 
>     I'm trying fit a survival model by maximum likelihood estimation
> using this function:
> 
> flver=function(a1,a2,b1,b2)
> {
> 
> lver=-(sum(st*log(exp(a1*x1+a2*x2)))+sum(st*log(hheft(exp(b1*x1+b2*x2)*t,f.heft)))
> -(exp(a1*x1+a2*x2)/exp(b1*x1-b2*x2))*sum(-log(1-pheft(exp(b1*x1+b2*x2)*t,f.heft))))
> }
> emv=mle(flver,start=list(a1=0,a2=0,b1=0,b2=0))
> 
> where hheft and pheft are functions defined in polspline package. 
> My variables are:
> t: time
> st: censor 
> x1 and x2: Covariates
> 
> I don't find any estimation because an error occurs:
> 
> Non finite/finite difference value [0].
> 
> Can I treat this error? I try using "SANN" method and this error occurs
> too. There is another alternative?

(Unlikely, given where in the code this occurs.  You haven't even copied 
it correctly!)

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list