[R] On nlm

Roger Bivand Roger.Bivand at nhh.no
Mon Jan 6 10:00:03 CET 2003


On Mon, 6 Jan 2003, E. D. Isaia wrote:

> Dear all, I have to minimize a (real) function in a loop (say i in 
> (1:1000)) and store its ``$estimate'', via 
> 
> l2estim<-nlm(f.minimo,c(-.01,0.1))$estimate
> 
> into a vector for further analisys.
> Since the function's behaviour is quite  peculiar (in the sense that in 
> the simulation study it may not have a minumum), sometimes I get the the 
> warning
> 
> Error in nlm(minimo, c(-0.01, 0.1), check.analyticals = FALSE) : 
> 	non-finite value supplied by nlm In addition: There were 50 or
> more warnings (use warnings() to see the first 50)
> 
> and the cicle stops. How can I avoid this and tell R that if so then
> l2estim<-0, for example.
> 
> Thanks to all, isaia.
> 

try() will probably be the best way to handle this - see ?try

Roger

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no




More information about the R-help mailing list