[R] How to set up a Negative Exponential regression mixed effect model 'nlme' ?
Ronny Steen
kestrel1978 at gmail.com
Thu Nov 17 23:13:48 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 have posted the question at R-SIG-mixed-models list, but no answer so
far, therefore I give it a new try here.
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 (similar to nls {stats} function
'negexp.SSival').
*My question:* Could I get some help adapting the Negative Exponential
regression model (*'nls'*, without random effect) to a model with nested
random effect (*'nlme' *)?
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-help
mailing list