I am having trouble figuring out the right form for the nlme arguments. I do
have examples in Modern and Applied Statistics with S and from other sources,
but I still can't figure it out.
I am trying to estimate species richness (sr) in streams across minnesota. My
predictor variables are depth (d), habitat diversity (habdiv), drainage area
(da) and an indicator variable representing the watershed/basins that the
streams are in (bas: there are 10 watersheds). The variable explaining the
greatest amount of variation appears to be da. I have used a log(da) to
linearize the relationship, but an asymptotic relationship is more appropriate.
I have used nls:
B<-c(.007,1,3,2,2,2,2,2,2,2,2,2,.05,.001,.8)
st<-list(ad=B[1],ahabdiv=B[2],abas=B[3:12],b=B[13],c=B[14],z=B[15])
modnls.a<-nls(sr~ad*log(d)+ahabdiv*habdiv+abas[bas]+(b/(c+(da^-z))),
start=st,trace=T)
I next used a random slope and intercept model using lmer from the package
(lme4).
modlme<-lmer(y~d+habdiv+log(da)+(log(da)|bas),method='ML')
What I would like to do is use a similar model to the modlme, but use
(b/(c+(da^-z))) instead of log(da). Keeping d and habdiv as fixed effects and
the sr-da relationship for each basin as a random effect. For the life of me I
can not figure out the proper form of nlme. Any help would be greatly
appreciated.
Fsr<-function(da,b,c,z){b/(c+(da^-z}
modnlme<-nlme(sr~d+habdiv+Fsr(da,b,c,z),
fixed=,
random=,
start=)