Chapter 8 Non linear model
8.1 Rectangular hyperbola of the Michaelis-Menten form
\[C=\frac{sR}{F+R}\]
Where
- C is resource consumption,
- R is the amount or density of the resource,
- s is the asymptotic value and
- F represents the density of resource at which half the asymptotic consumption is expected to occur. This model is not linear in its parameters.
8.1.1 Fitting model
Starting values need to be provided. Plot the data first to estimate the asymptote
d<-read.csv("/home/aqm/course/data/Hollings.csv")
g0<-ggplot(data=d,aes(x=Resource,y=Consumption)) + geom_point()
g0
8.1.2 Fitting the model
nlmod<-nls(Consumption~s*Resource/(F+Resource),data = d,start = list( F = 20,s=20))
8.1.3 Curve fit
g0<-ggplot(data=d,aes(x=Resource,y=Consumption))
g1<-g0+geom_point()
g2<-g1+geom_smooth(method="nls",formula=y~s*x/(F+x),method.args=list(start = c( F = 20,s=20)), se=FALSE)
g2
8.1.4 Curve fit with confidence intervals
This needs the propagate package.
require(propagate)
newdata<-data.frame(Resource=seq(min(d$Resource),max(d$Resource),length=100))
pred_model <- predictNLS(nlmod, newdata=newdata,nsim = 10000)
conf_model <- pred_model$summary
newdata<-data.frame(newdata,conf_model)
g2 + geom_line(data=newdata,aes(x=Resource,y=Prop.2.5.),col="black",lty=2) + geom_line(data=newdata,aes(x=Resource,y=Prop.97.5.),col="black",lty=2)
8.2 Holling’s disc equation
The classic version of Hollings disk equation used in the article is written as
\(R=\frac{aD}{1+aDH}\)
Where
- F = feeding rate (food items)
- D = food density (food items \(m^{-2}\))
- a = searching rate (\(m^{2}s^{-1}\))
- H = handling time (s per food item).
8.2.1 The data
d<-read.csv("/home/aqm/course/data/buntings.csv")
g0<-ggplot(data=d,aes(x=density,y=rate)) + geom_point()
g0
8.2.2 Fitting the model
d<-read.csv("/home/aqm/course/data/buntings.csv")
HDmod<-nls(rate~a*density/(1+a*density*H),data = d,start = list(a =0.001,H=2))
8.2.3 Confidence intervals for parameters
confint(HDmod)
## 2.5% 97.5%
## a 0.002593086 0.006694939
## H 1.713495694 1.976978655
8.2.4 Plot with fitted curve
g0<-ggplot(data=d,aes(x=density,y=rate))
g1<-g0+geom_point()
g2<-g1+geom_smooth(method="nls",formula=y~a*x/(1+a*x*H),method.args=list(start = c(a = 0.01,H=2)), se=FALSE)
g2
8.2.5 Plot with confidence intervals
require(propagate)
newdata<-data.frame(density=seq(0,max(d$density),length=100))
pred_model <- predictNLS(HDmod, newdata=newdata,nsim = 10000)
conf_model <- pred_model$summary
newdata<-data.frame(newdata,conf_model)
g3<-g2 + geom_line(data=newdata,aes(x=density,y=Prop.2.5.),col="black",lty=2) + geom_line(data=newdata,aes(x=density,y=Prop.97.5.),col="black",lty=2)
g3
8.2.6 Non linear quantile regression
library(quantreg)
QuantMod90<-nlrq(rate~a*density/(1+a*density*H),data = d,start = list(a =0.001,H=2),tau=0.9)
QuantMod10<-nlrq(rate~a*density/(1+a*density*H),data = d,start = list(a =0.001,H=2),tau=0.1)
newdata$Q90<- predict(QuantMod90, newdata = newdata)
newdata$Q10 <- predict(QuantMod10, newdata = newdata)
g3 + geom_line(data=newdata,aes(x=density,y=Q90),col="red") + geom_line(data=newdata,aes(x=density,y=Q10),col="red")