Created
October 13, 2011 15:04
-
-
Save sckott/1284442 to your computer and use it in GitHub Desktop.
Example use case of PGLMMs for phylogenetic community structure
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Example Code | |
# Load functions | |
source("/path/where/you/have/this/file/PGLMM.data.R") | |
source("/path/where/you/have/this/file/PGLMM.fit.R") | |
source("/path/where/you/have/this/file/PGLMM.reml.R") | |
source("/path/where/you/have/this/file/PGLMM.sim.R") | |
# Simulate a dataset for the example | |
modelflag <- 1 | |
sim.dat <- PGLMM.sim(stree(16, "balanced"), nsites = 30, modelflag = modelflag, | |
second.env = TRUE, compscale = 1) | |
sim.dat$Vphylo # I think this is the variance-covariance matrix from the phylogeny | |
# PGLMM.sim also automatically outputs three figures, shown below | |
# Organizes the data so that PGLMM can be fit | |
dat <- PGLMM.data(modelflag=modelflag,sim.dat=sim.dat) | |
str(dat) # Structure of the data | |
# Simulate a dataset for the example | |
# low number of iterations, maxit = 25 is probably good, but may need | |
# to increase exitcountermax | |
out <- PGLMM.fit(dat = dat, maxit = 25, exitcountermax = 30) | |
str(out) # Structure of the data | |
out$B # coefficients from PGLMM | |
out$B0 # coefficients from standard logistic regression | |
out$s # parameter(s) of the covariance matrix | |
out$LL # log-likelihood | |
out$flag # did model converge? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment