[R] lme, nlsList, nlsList.selfStart

Patrick Giraudoux patrick.giraudoux at univ-fcomte.fr
Sun Feb 12 08:44:24 CET 2006


Dear listers,

I am trying to fit a model using nlsList() using alternately a SSfol() 
selfstart function or its developped equivalent formulae.

This preliminary trial works well

mydata<-groupedData(Conc~Tps|Organ,data=mydata)
mymod1<-nls(Conc~SSfol(Dose,Tps,lKe,lKa,lCl),data=mydata)

as well as a developped form:

mymod2<-nls(Conc~Dose * exp(lKe+lKa-lCl) * 
(exp(-exp(lKe)*Tps)-exp(-exp(lKa)*Tps)) /(exp(lKa)-exp(lKe)),
    data=mydata,
    start= c(lKe=-2.77, lKa=-1.41, lCl=-1.13)
    )

However when trying to fit the model with nlsList, I get:

mymod3<-nlsList(Conc~Dose * exp(lKe+lKa-lCl) * 
(exp(-exp(lKe)*Tps)-exp(-exp(lKa)*Tps)) /(exp(lKa)-exp(lKe)),
     data=mydata,
     start= c(lKe=-2.77, lKa=-1.41, lCl=-1.13)
     )
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
        variable lengths differ
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
        variable lengths differ
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
        variable lengths differ

Or specifying  the grouping factor explicitely:

mymod3<-nlsList(Conc~Dose * exp(lKe+lKa-lCl) * 
(exp(-exp(lKe)*Tps)-exp(-exp(lKa)*Tps)) /(exp(lKa)-exp(lKe))|Organ,
     data=mydata,
     start= c(lKe=-2.77, lKa=-1.41, lCl=-1.13)
     )

Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
        variable lengths differ
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
        variable lengths differ
Error in model.frame(formula, rownames, variables, varnames, extras, 
extranames,  :
        variable lengths differ


I cannot find out why the grouping factor cannot be used (it has the 
same length as the other variables...)

Another strange thing occurs: in the example given in the help of 
nlsList.selfstart, the following command works  well:

 fm1 <- nlsList(SSasympOff, CO2)

However its seemingly equivalent applied to the case above fails:

mymod4<-nlsList(SSfol,data=mydata)
Error in eval(expr, envir, enclos) : object "input" not found
Error in eval(expr, envir, enclos) : object "input" not found
Error in eval(expr, envir, enclos) : object "input" not found


Any hint/suggestion appreciated.

Kind regards,

Patrick Giraudoux




More information about the R-help mailing list