[R] nls and na/Nan/Inf error

Tony Meissner tony.meissner at bigpond.com
Mon Sep 26 07:14:24 CEST 2005


I am trying to it a particular nonlinear model common in Soil Science to 
moisture release data from soil.  I have written the function as shown 
below according to the logist example in Ch8 of Pinheiro & Bates.  I am 
getting the following error (R version 2.1.1)

*Error in qr(attr(rhs, "gradient")) : NA/NaN/Inf in foreign function 
call (arg 1)*

Below is the function and data.

/# the van genuchten moisture release function
vanGen <- function(x, Vr, Vm, alpha, lamda) {
  if (Vr < 0) Vr <- 0
  Vr + (Vm - Vr)/((1+(alpha*x)^lamda)^(1-1/lamda))
  }
vanGen <- deriv(~Vr + (Vm - Vr)/((1+(alpha*x)^lamda)^(1-1/lamda)),
  c("Vr", "Vm", "alpha", "lamda"), function(x, Vr, Vm, alpha, lamda) {} )/


the call in R

/> fm1fld.nls <- nls(Moisture ~ vanGen(Suction, Vr,Vm,alpha,lamda),
+ data=fldgd, start=c(Vr=0.229, Vm=0.433, alpha=0.2, lamda=1.5))

/and the data:/

/*   Suction Moisture
1        0    0.433
2        1    0.421
3        4    0.400
4       10    0.379
5       20    0.366
6       30    0.362
7       40    0.358
8       50    0.353
9       60    0.351
10      70    0.349
*/
/can anyone offer any suggestions.  The parameters Vr, Vm >= 0,  alpha > 
0, and
lamda > 1




More information about the R-help mailing list