[R] first value from nlm (non-finite value supplied by nlm)

Thomas Bock Thomas.Bock at ptb.de
Fri Oct 24 13:22:31 CEST 2003


Dear expeRts,

first of all I'd like to thank you for the
quick help on my last which() problem.

Here is another one I could not tackle:
I have data on an absorption measurement which I want to fit
with an voigt profile:

  fn.1 <- function(p){
    for (i1 in ilong){
      ff <- f[i1]
      ex[i1] <- exp(S*n*L*voigt(u,v,ff,p[1],p[2],p[3])[[1]])
    }
sum((t-ex)^2)
  }
out <- nlm(fn.1, p = c(fo, GG, GL), hessian = TRUE, steptol = 1e-5, 
iterlim = 1000)
foN <-  out$estimate[1]
GGN <-  out$estimate[2]
GLN <-  out$estimate[3]

This works fine but the my start value of S is to poor,
so I like to fit S in a second run, with the initial values from the 
first run
(two runs because I know that S as an parameter is an problem):

  fn.2 <- function(p){
    for (i1 in ilong){
      ex[i1] <- exp(p[1]*n*L*voigt(u,v,f[i1],p[2],p[3],GLN)[[1]])
          }
 sum((t-ex)^2)
}
out <-nlm(fn.2, p = c(S,foN,GGN), hessian = TRUE,
           steptol = 1e-5, iterlim = 1000,print.level=2)
SN <-  out$estimate[1]

The problem is now that the first value from nlm() is positive (1E-6 !?)
and this leeds to an Inf:

  iteration = 0
Step:
[1] 0 0 0
Parameter:
[1] -3.800000e-19  2.196660e+03  5.211179e-03
Function Value
[1] 0.5890603
Gradient:
[1]       Inf  11.23381 -23.61961 -
 
Error in nlm(fn.2, p = c(S, foN, GGN), hessian = TRUE, steptol = 1e-5,  :
    non-finite value supplied by nlm
In addition: Warning message:
NA/Inf replaced by maximum positive value

The number of parameters plays no role; same behaviour with p = c(S,GGN)

Can someone give a broad hint
             Thomas




More information about the R-help mailing list