MCMC_nLTT: Code to perform Metropolis-Hastings MCMC for a...

Description Usage Arguments Value Author(s) Examples

Description

This function performs Metropolis-Hastings MCMC, where the user provides a likelihood function and a phylogenetic tree.

Usage

1
2
mcmc_nltt(phy, likelihood_function, parameters, logtransforms,
		  iterations, burnin = round(iterations / 3), thinning = 1, sigma=1)

Arguments

phy

an object of class "phylo"; the tree upon which we want to fit our diversification model

likelihood_function

Function that calculates the likelihood of our diversification model, given the tree. Function should me of the format function(parameters,phy).

parameters

Initial parameters to start the chain.

logtransforms

Whether to perform jumps on logtransformed parameters (TRUE) or not (FALSE)

iterations

Length of the chain

burnin

Length of the burnin, default is 30

thinning

Size of thinning, default = 1

sigma

Standard deviation of the jumping distribution, which is N(0, sigma).

Value

An MCMC object, as used by the package "coda".

Author(s)

Sebastian Hoehna & Thijs Janzen

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
## MCMC examples are typically very slow ####
## Not run: 

require(TESS);

obs <- TESS.sim.age(n = 1, lambda = 0.5, mu = 0.1, age = 10)[[1]];

LL_BD <- function(params, phy) {
 lnl <- tess.likelihood(phy, lambda = params[1], mu = params[2],
 							  samplingProbability = 1, log = TRUE);
 prior1 <- dunif( params[1], 0, 100, log = TRUE)
 prior2 <- dunif( params[2], 0, 100, log = TRUE);
 return(lnl + prior1 + prior2);
}

require(coda);

mcmc_out <- mcmc_nltt(obs, LL_BD, c(0.5, 0.1), c(TRUE, TRUE),
			iterations = 1000, burnin = 100, thinning = 10, sigma = 1)
plot(mcmc_out);

## End(Not run)

nLTT documentation built on Jan. 13, 2020, 9:06 a.m.