[R] nlsList vs nlme with lsoda function
Manuel Morales
Manuel.A.Morales at williams.edu
Tue Feb 15 18:24:31 CET 2005
Hello list members,
I'm trying to get nlme to work with lsoda from odesolve. Currently, I
can use nlsList to fit a simple logistic growth model to some simulated
data, but I get the following error message with nlme: "Error in
model.frame(formula, rownames, variables, varnames, extras, extranames,
: invalid variable type"
The commands I'm trying are below. Any suggestions for how to get this
to work?
Thanks!
This works:
fit.nlsList<-nlsList(xvals~lsoda(x0,times,Logist,
+c(r=r,K=K,x0=x0))[,2]|group,
+start=list(r=1,K=500,x0=2),data=data.group)
This returns the error message above:
fit.nlme<-nlme(xvals~(lsoda(x0,times,Logist,
+c(r=r,K=K,x0=x0))[,2]),
+start=list(r=1,K=500,x0=2),data=data.group,
+fixed=r+K+x0~1,random=x0~1)
The model function is:
Logist=function(t,x,parms) {
N1<-x[1]
with(as.list(parms),{
dN1=r*N1*(1-(N1/K))
list(c(dN1))
})}
My data set looks like:
Grouped Data: xvals ~ times | group
xvals times group
1 -0.44543969 0 1
2 38.86411972 3 1
3 310.77106961 6 1
4 486.78653327 9 1
5 0.40613173 0 2
6 34.94635643 3 2
7 307.81884870 6 2
8 486.46098417 9 2
etc...
More information about the R-help
mailing list