[R-sig-ME] How to do exponential regression mixed effect model with function 'negexp.SSival'?
Ronny Steen
kestrel1978 at gmail.com
Mon Nov 14 10:14:46 CET 2016
Hi,
I need help with fitting a non-linear mixed effects model (nested random
effect). I look at the relationship between 'wingbeat frequency' (beats per
sec) and 'wing length' in hummingbirds, and I will find a model with the
best fit.
I manage to fit Negative Natural Exponential regression and Assymptotic
(SSasymp-function) nonlinear regression, but I don't figure out how to fit
Negative Exponential regression (negexp.SSival) with nested random effect.
*My question:* Could I get some help adapting the Negative Exponential
regression model (*'nls'*, without random effect) to model with nested
random effect (*'nlme' or ''lme4*)?
Script and access to data:
library(nlme)
library(MASS)
WBF <-read.csv(url("
https://www.dropbox.com/s/hin8o27i1kmdloe/Species2016.csv.csv?raw=1"))
plot(WBF$WL,WBF$Beat_freq,type="p",ylab="WBF")# Make a plot
#Negative Natural Exponential regression with nested random effect
fm1<-lme(Beat_freq ~ exp(-WL),
data = WBF,
random = ~ 1|Species/ID, method = "ML")
#Assymptotic (SSasymp-function) nonlinear regression with nested random
effect
fm2 <- nlme(Beat_freq ~ SSasymp(WL, Asym, R0, lrc),
data = WBF,
fixed = Asym + R0 + lrc ~ 1,
random = Asym ~ 1|Species/ID,
start = c(Asym = 27, R0 = 6000, lrc = 0.19))
#Negative Exponential regression - HELP NEEDED TO INCLUDE NESTED RANDOM
EFFECT ('nlme')
negexp<-selfStart(model = ~b0 + b1*exp(-x/th), initial =
negexp.SSival,parameters=c("b0","b1","th"),
template=function(x,b0,b1,th){})
fm3<-nls(Beat_freq~negexp(WL,B0,B1,theta),
data=WBF,control=list(maxiter =5000),trace=T)
Regards,
Ron
[[alternative HTML version deleted]]
More information about the R-sig-mixed-models
mailing list