[R] nlme model

From: Daniel O'Shea <dan.oshea_at_dnr.state.mn.us>
Date: Tue, 12 Jun 2007 11:27:14 -0500


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=)



R-help_at_stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code. Received on Tue 12 Jun 2007 - 16:34:58 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Tue 12 Jun 2007 - 17:31:48 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.