read.mulTree: Reads MCMCglmm models fromn mulTree.

View source: R/read.mulTree.R

read.mulTreeR Documentation

Reads MCMCglmm models fromn mulTree.

Description

Reads MCMCglmm objects from the mulTree function back into the R environment.

Usage

read.mulTree(mulTree.chain, convergence = FALSE, model = FALSE, extract = NULL)

Arguments

mulTree.chain

A chain name of MCMCglmm models written by the mulTree function.

convergence

Logical, whether to read the convergence file associated with the chain name (default = FALSE).

model

Logical, whether to input a single MCMCglmm model or the list of random and fixed terms only (default = FALSE).

extract

Optional, the name of one or more elements to extract from each model (rather than loading the full model; default = NULL).

Details

The argument model = TRUE can be used to load the MCMCglmm object of a unique chain. The resulting object can be then summarized or plotted as S3 method for class MCMCglmm.

Value

A list of the terms of class mulTree by default. Else a MCMCglmm object (if model = TRUE); a gelman.diag object (if convergence = TRUE) or a list of extracted elements from the MCMCglmm models (if extract is not NULL).

Author(s)

Thomas Guillerme

See Also

mulTree, plot.mulTree, summary.mulTree

Examples

## Creating some dummy mulTree models
data <- data.frame("sp.col" = LETTERS[1:5], var1 = rnorm(5), var2 = rnorm(5))
tree <- replicate(3, rcoal(5, tip.label = LETTERS[1:5]), simplify = FALSE)
class(tree) <- "multiPhylo"
mulTree.data <- as.mulTree(data, tree, taxa = "sp.col")
priors <- list(R = list(V = 1/2, nu = 0.002),
     G = list(G1 = list(V = 1/2, nu = 0.002)))
mulTree(mulTree.data, formula = var1 ~ var2, parameters = c(10000, 10, 1000),
     chains = 2, prior = priors, output = "quick_example", convergence = 1.1,
     ESS = 100, verbose = FALSE)

## Reading all the models
all_chains <- read.mulTree("quick_example")

## Reading the convergence diagnosis for all the trees
read.mulTree("quick_example", convergence = TRUE)

## Reading a specific model
model <- read.mulTree("quick_example-tree1_chain1", model = TRUE)

## Reading only the error term and the tune for all models
read.mulTree("quick_example", extract=c("error.term", "Tune"))

##Remove the generated files from the current directory
file.remove(list.files(pattern = "quick_example"))


TGuillerme/mulTree documentation built on Feb. 21, 2024, 9:18 a.m.