8 Phylogenetic ANOVA

So far, we have only analysed continuous quantitative characters. But it is also possible to perform an ANOVA with PGLS.

The great thing with PGLS as implemented with the gls function is that it can easily be adapted to testing many different types of models. To give just one example here, it is easy to implement a phylogenetic ANOVA in R. Indeed, you just need to give gls a categorical trait as independent variable.

Because there is no categorical variable in the plant functional trait dataset, we will create one by dividing the wood density category in two categories, light and dense wood.

# Make categorical variable
seedplantsdata$Wd.cat<-cut(seedplantsdata$Wd,breaks=2,labels=c("light","dense"))
# Look at the result
seedplantsdata$Wd.cat
##  [1] light light dense light dense dense dense light light light light dense
## [13] dense light light dense dense dense dense dense dense dense light dense
## [25] light dense light light dense dense light light light light light light
## [37] light light light light light light light light light dense dense dense
## [49] dense light light light light light light light dense
## Levels: light dense

We can now fit a phylogenetic ANOVA.

# Phylogenetic ANOVA
shade.pgls3 <- gls(Shade ~ Wd.cat, data = seedplantsdata, correlation=pagel.corr)
summary(shade.pgls3)
## Generalized least squares fit by REML
##   Model: Shade ~ Wd.cat 
##   Data: seedplantsdata 
##        AIC      BIC    logLik
##   166.7352 174.7646 -79.36762
## 
## Correlation Structure: corPagel
##  Formula: ~Code 
##  Parameter estimate(s):
##    lambda 
## 0.9439646 
## 
## Coefficients:
##                 Value Std.Error  t-value p-value
## (Intercept) 2.6826723 1.3844404 1.937730  0.0578
## Wd.catdense 0.6179855 0.2526902 2.445626  0.0177
## 
##  Correlation: 
##             (Intr)
## Wd.catdense -0.037
## 
## Standardized residuals:
##         Min          Q1         Med          Q3         Max 
## -0.69257567 -0.48677930 -0.04143001  0.33640615  0.95379525 
## 
## Residual standard error: 2.429586 
## Degrees of freedom: 57 total; 55 residual

You can see that the wood density, even when transformed in a categorical variable, has a significant effect on shade tolerance.