Free Access Week - Data Engineering + BI
Data Engineering and BI courses are free this week!
Free Access Week - Jun 2-8

picante (version 1.5-1)

pglmm: Phylogenetic Generalized Linear Mixed Model

Description

Fit the presence/absence of species across communities to environmental, trait and phylogenetic data with generalized linear mixed models.

Usage

pglmm.sim(tree,nsites=30,modelflag=1,figs=TRUE,second.env=TRUE,compscale = 1)
pglmm.data(modelflag=1,sim.dat=NULL,samp=NULL,tree=NULL,traits=NULL,env=NULL,Vcomp=NULL)
pglmm.fit(dat=NULL,Y=NULL,X=NULL,VV=NULL,sp.init=0.5,maxit=25,exitcountermax=50)

Arguments

tree
Object of class phylo or a phylogenetic covariance matrix
nsites
Number of sites to simulate
modelflag
A number 1 - 5 indicating data set structure and corresponding to one of the models in Ives and Helmus (2011)
figs
Generate figures
compscale
compscale
second.env
Simulate community data with two environmental covariates
sim.dat
Object from pglmm.sim
samp
Species (rows) by site (columns) community data matrix
traits
Species X trait data matrix
env
Site X environment data matrix
Vcomp
Species X species matrix of pairwise repulsion
dat
A list with Y, X and VV from pglmm.sim or similarly structured in the same way
Y
The dependent variable, a (species times site) X 1 matrix of 0 and 1
X
The independent variables, a (species times site) X (trait + environment) matrix
VV
A list of the covariance matrices one for each random effect
sp.init
Initial values of the variances of the random effects (e.g., phylogenetic signal)
maxit
maxit in optim used to estimate the GLMM
exitcountermax
Number of iterations to estimate the fixed effect coefficients with penalized quasilikelihood and the variances of the random effects with restricted maximum likelihood

Value

  • pglmm.sim returns a list with items:
  • VphyloPhylogenetic covariance matrix
  • VcompRepulsion matrix
  • YCommunity presence/absence matrix
  • XProbabilities of a species being found in a community
  • uEnvironmental gradient
  • bspp1Species tolerances to environmental gradient 1 (phylogenetic signal)
  • bspp2Species tolerances to environmental gradient 2 (no phylogenetic signal)
  • pglmm.data returns a list with items:
  • YYIndependent variable
  • VVCovariance matrices for the random effects
  • XXDependent variables
  • pglmm.fit returns a list with items:
  • BCoefficient estimates
  • B0Initial estimates of the coefficients
  • sThe estimates of the scaling parameters (fitted variances) for the random effects (e.g., estimate of phylogenetic signal in community composition)
  • LLLog likelihood of the final fitted PGLMM
  • flagDid the estimation procedure converge?

Details

Phylogenetic Generalized Linear Mixed Models (PGLMM) are generalized linear mixed model designed to test for phylogenetic patterns in community structure. Five models are implemented here and are designed to address (1) phylogenetic patterns in community structure, (2) phylogenetic variation in species sensitivities to environmental gradients among communities, (3) phylogenetic repulsion in which closely related species are less likely to co-occur, (4) trait-based variation in species sensitivities to environmental gradients, and (5) the combination traits and phylogeny to explain the variation in species occurrences among communities. Many other models can be designed by differently structuring the independent variable (Y), dependent variables (X), and covariance matrices (VV). This can be done by either editing the pglmm.data code or designing these objects by hand with custom code.

References

Ives A.R. & Helmus M.R. (2011). Generalized linear mixed models for phylogenetic analyses of community structure. Ecological Monographs, 81, 511-525.

See Also

phylostruct

Examples

Run this code
modelflag=1
sim.dat<-pglmm.sim(stree(16, "balanced"),nsites=30,modelflag=modelflag,second.env=TRUE,compscale=1)
str(sim.dat)

dat<-pglmm.data(modelflag=modelflag,sim.dat=sim.dat)
str(dat)

#A low number of iterations, maxit = 25 is probably good for most data sets, but exitcountermax may need to be increased depending on matrix sizes
out<-pglmm.fit(dat=dat,maxit=25,exitcountermax=30)
str(out)
out$s # The first row gives the estimate of phylogenetic signal and the second an estimate of how strongly species richness varies across communities. This later parameter is likely biologically uninformative for most research questions.

Run the code above in your browser using DataLab