equiv | R Documentation |
membership to equivalency matrix
For a vector with entries indicating partition membership, thus function returns an equivalency matrix describing vector elements belong to the same partition
equiv(v)
v |
a vector |
numerical equivalency relationship matrix, with 1s use indicating equivalency and zeros otherwise
# load tree
tr <- ape::read.tree("~/Trachylepis-tree_WithAllOutgroups_NewNames2.new")
# load matrix of tip names and tip priors
tp <- as.matrix(read.csv("~/Trachylepis_parity_20Aug2018.csv", row.names=1))
# names of character states
st <- colnames(tp)
# generate all possible models
mod <- transitionModels(st)
## fit the first 20 transition rates model scheme to the data, and use a uniform prior for the root state.
test1 <- fitmodels(tree=tr,priors.tips=as.matrix(tp),model.transitions=mod[1:20])
bestModel <- test1$models[[which(test1$AIC==min(test1$AIC))]]
make.bestModel <- phytools::make.simmap(tr,tp,model=bestModel, nsim=1000)
describe.bestModel <- phytools::describe.simmap(make.bestModel,plot=F)
plot(describe.bestModel)
## fit the first 10 transition rates model scheme to the data, and set the root state prior to c(0,1,0) for the three character states.
test2 <- fitmodels(tree=tr,priors.tips=as.matrix(tp),model.transitions=mod[1:10],priors.root=c(0,1,0))
bestModel2 <- test2$models[[which(test2$AIC==min(test2$AIC))]]
make.bestModel2 <- phytools::make.simmap(tr,tp,model=bestModel2, nsim=1000)
describe.bestModel2 <- phytools::describe.simmap(make.bestModel2,plot=F)
plot(describe.bestModel2)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.