gls.ci / gls.pi

The functions ‘gls.ci’ and ‘gls.pi’ compute the confidence and prediction intervals of a bivariate generalized least-squares model. When the covariance among data points is based on the phylogenetic covariance, these functions compute the confidence and prediction intervals of the phylogenetic regression (pGLS).

Reference: Smaers JB & Rohlf FJ. Testing species’ deviations from allometric predictions using the phylogenetic regression. Evolution. 70 (5): 1145-1149.

Below a case study to exemplify the use of these functions.

Prepare the analysis

require(phytools); require(geiger); require(nlme); require(evomap)
data<-primateData
tree<-primateTree
data<-log(data) 
tree<-treedata(tree,data,sort=T,warnings=T)$phy
data<-as.data.frame(treedata(tree,data,sort=T,warnings=T)$data)

Run a phylogenetic regression of brain size to body size

pGLS<-gls(Brain~Body,data,correlation=corBrownian(phy=tree))
 summary(pGLS)
plot(Brain~Body,data=data,pch=19,cex=2,cex.lab=1)
 abline(pGLS)

Compute and plot the pGLS confidence intervals

pGLS_ci<-gls.ci(data$Brain,data$Body,vcv(tree))
 lines(pGLS_ci$CI.plot$X,pGLS_ci$CI.plot$Lower2.5,lty=2)
 lines(pGLS_ci$CI.plot$X,pGLS_ci$CI.plot$Upper2.5,lty=2)

Compute and plot the pGLS prediction intervals

pGLS_pi<-gls.pi(data$Brain,data$Body,vcv(tree),1)
 lines(pGLS_pi$PI.plot$X,pGLS_pi$PI.plot$Lower2.5,lty=3)
 lines(pGLS_pi$PI.plot$X,pGLS_pi$PI.plot$Upper2.5,lty=3)

 


The above procedures can be extrapolated to incorporating various models of evolution by adjusting the variance-covariance matrix of the tree according to relevant model parameters (e.g. the lambda parameter).