[R] Help specifying a non-linear model in nlsLM()

Chandrasekhar Rudrappa chandratr at gmail.com
Tue Dec 16 15:26:30 CET 2014

Dear All,

I am trying to fit the following model in nlsLM():

fn5 <- function(x, T, t1, w_inf, Lt0){
S<-function(x, T, t1){
F <- function(x, T, t1){
t2 <- t1 + (1-T)/2
t3 <- t1 + (1+T)/2
t.factorial <- x%%1
floor(x)*(1-T) + S(t.factorial, T, t1)*(0<=t.factorial & t.factorial<t2) +
S(t2, T, t1)*(t2<=t.factorial & t.factorial<t3) +
S(t.factorial-T, T, t1)*(t3<=t.factorial & t.factorial<1)
return(w_inf - (w_inf - Lt0)*exp(-(2/30)*(F(x,T,t1)-F(7,T,t1))))
fn6<- y~fn5(x, T, t1, w_inf, Lt0)
startval<-c(x=x, T=0.035, t1=0.359, w_inf=135, Lt0=47)
(nlsktm1 <- nlsLM(fn6, start=startval, lower=c(x=x, T=0.0135, t1=0.259,
w_inf=131, Lt0=41), jac=NULL, trace=T, data=ktm,

When I run the above script, the following error is displayed:

Error in nlsModel(formula, mf, start, wts) :
  singular gradient matrix at initial parameter estimates
In addition: Warning message:
In nls.lm(par = start, fn = FCT, jac = jac, control = control, lower =
lower,  :
  lmdif: info = 0. Improper input parameters.

Suitable help is requested.
Dr. TR Chandrasekhar, M.Sc., M. Tech., Ph. D.,
Sr. Scientist
Rubber Research Institute of India
Hevea Breeding Sub Station
Kadaba - 574 221
DK Dt., Karnataka
Phone-Land: 08251-214336
Mobile: 9448780118

	[[alternative HTML version deleted]]

More information about the R-help mailing list