[R] Error with nls

1-27206531-0-90000491 domi at sun11.ukl.uni-freiburg.de
Thu Mar 28 19:40:50 CET 2002


Thank for the advice.

I repeated the call of nls with option: trace=TRUE:

> m2 <- nls(y ~ L5L6(b40, b4i, k4, t, p50, p56, p60, p65, pc, ph, pd,
pb50, pb60), 
+ data=help, start=c(p50=0.008678954, p56=-0.595153967, p60=-4.602990518,
p65=-0.625732096, 
+ pc=-0.128657978, ph=0.708033556, pd=1.140357461, pb50=1.311141424,
pb60=1.270852258),
+ trace=TRUE)
4189.237 :   0.008678954 -0.595153967 -4.602990518 -0.625732096
-0.128657978  0.708033556  1.140357461  1.311141424  1.270852258 
Error in numericDeriv(form[[3]], names(ind), env) : 
        Missing value or an Infinity produced when evaluating the model

Excuse me, but I did not know, how I should interpretate it, or what
consequences I have to do.

Kind regards,

Dominik

On 27 Mar 2002, Douglas Bates wrote:

> 1-27206531-0-90000491 <domi at sun11.ukl.uni-freiburg.de> writes:
> 
> >  I use:
> >  
> >  platform i386-pc-mingw32
> >  arch     x86            
> >  os       Win32          
> >  system   x86, Win32     
> >  status                  
> >  major    1              
> >  minor    4.1            
> >  year     2002           
> >  month    01             
> >  day      30             
> >  language R
> 
> Thank you for providing that information.
> 
> >  I try to fit a 2 compartment model. The compartments are open, connected
> >  to each other and are filled via constant input and a time depended
> >  function as well. Data describes increasing of Apo B after dialysis. Aim
> >  of the analysis is to test the hypothesis whether the data could described
> >  by two simple disconnected one compartment modes ore the "saturated
> >  model" holds? The first order differential equation for the saturated
> >  model:
> >  
> >  db5 = - (k50+k56)*b5 + k56*b6 + c*g(t) + h
> >  db6 = + k65*b5 - (k60+k65)*b6 + d
> >  
> >  db5, db6 are the first derivatives, b5, b6 are the functions to be
> >  fitted. The remaining parameters are unknown and should follow from the
> >  fit.
> >  
> >  assuming that g(t) has the functional form: b4i + (b40-b4i)*exp(-k4*t)
> >  
> >  (after calculations of 2 papers of A4) follows the solution:
> >  
> >  L5L6 <- function(b40, b4i, k4, t, p50, p56, p60, p65, pc, ph, pd, pb50,
> >  pb60) {
> >  
> >  	k50 <- exp(p50)
> >  	k56 <- exp(p56)
> >  	k60 <- exp(p60)
> >  	k65 <- exp(p65)
> >  	c   <- exp(pc)
> >  	h   <- exp(ph)
> >  	d   <- exp(pd)
> >  	b50 <- exp(pb50)
> >  	b60 <- exp(pb60)
> >  	a <- (k50+k56)
> >  	b <- k65
> >  	e <- k56
> >  	f <- (k60+k65)
> >  	z1 <- (-(a+f)/2 - sqrt((a+f)^2/4 - a*f + b*e))
> >  	z2 <- (-(a+f)/2 + sqrt((a+f)^2/4 - a*f + b*e))
> >  	K  <- ((z1+a)/(z2-z1))
> >  	B1 <- (b/(z2-z1)*b60 - K*b50)
> >  	A1 <- (b50-B1)
> >  	X1 <- (b*d/(z2-z1)-K*(c*b4i+h))
> >  	X2 <- (K*c*(b4i-b40))
> >  	X3 <- (c*b4i + h - X1)
> >  	X4 <- (c*(b40-b4i)- X2)
> >  	C1E <- (X3/(-z1)*(1-exp(z1*t)) +
> >  X4/(-(k4+z1))*(exp(-k4*t)-exp(z1*t)))
> >  	C2E <- (X1/(-z2)*(1-exp(z2*t)) +
> >  X2/(-(k4+z2))*(exp(-k4*t)-exp(z2*t)))
> >  	b5 <- (A1*exp(z1*t) + B1*exp(z2*t) + C1E + C2E)
> >  	b6 <- ((z1+a)/b * A1*exp(z1*t) + (z2+a)/b * B1*exp(z2*t) +
> >  (z1+a)/b * C1E + (z2+a)/b * C2E)
> >  	y <- f5*b5 + f6*b6
> >  	return(y)
> >  }
> >  
> >  I am in the lucky circumstances having starting values, because a nlr-fit
> >  succeeds, the graphical presentation of the fits looks quite nice. The nlr
> >  function is part of Lindsey's library(gnlm), but now I would like to apply
> >  Pinheiro and Bates library(nlme) and I have got an error:
> >  
> > > m2 <- nls(y ~ L5L6(b40, b4i, k4, t, p50, p56, p60, p65, pc, ph, pd,
> > > pb50, pb60), 
> > > + data=help, start=c(p50=0.008678954, p56=-0.595153967,
> > > + p60=-4.602990518, p65=-0.625732096, 
> > > + pc=-0.128657978, ph=0.708033556, pd=1.140357461, pb50=1.311141424,
> > > + pb60=1.270852258))
> > > Error in numericDeriv(form[[3]], names(ind), env) : 
> > >         Missing value or an Infinity produced when evaluating the model
> > > 
> >  If somebody feel that he can help me, I could send him my R- code and
> >  data file as well.
> 
> It is likely that the iterative algorithm is progressing to values of
> the parameters that don't make sense physically.  I suggest that you
> add trace = TRUE to your call to nls.  This will provide a record of the
> parameter values, the residual sum of squares, and the convergence
> criterion throughout the iterations.
> 
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
> Send "info", "help", or "[un]subscribe"
> (in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
> 
> 

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !)  To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._



More information about the R-help mailing list