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)
pglmm.sim
list
with Y
, X
and VV
from pglmm.sim
or similarly structured in the same waymaxit
in optim
used to estimate the GLMMpglmm.sim
returns a list with items:pglmm.data
returns a list with items:pglmm.fit
returns a list with items: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.phylostruct
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