[R] Error with nls

1-27206531-0-90000491 domi at sun11.ukl.uni-freiburg.de
Wed Mar 27 10:47:31 CET 2002

 Dear R-group members,
 I use:
 platform i386-pc-mingw32
 arch     x86            
 os       Win32          
 system   x86, Win32     
 major    1              
 minor    4.1            
 year     2002           
 month    01             
 day      30             
 language R
 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
 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
 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)) +
 	C2E <- (X1/(-z2)*(1-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
 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.
 Kind regards,

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