View source: R/tess.PathSampling.R
tess.pathSampling | R Documentation |
tess.pathSampling uses a power posterior series and path-sampling to estimate the marginal likelihood of a model. This is a very general implementation of this algorithm which can be applied basically to any model. More information can be obtained in the vignette about how to apply this method.
tess.pathSampling(likelihoodFunction,priorFunction,parameters,logTransforms, iterations,burnin=round(iterations/3),K=50)
likelihoodFunction |
The log-likelihood function which will be called internally by likelihoodFunction(parameters). |
priorFunction |
A list of functions of the log-prior-densities of each parameter. |
parameters |
The initial parameter value list. |
logTransforms |
A vector of booleans telling if log-transform for the parameters should be used (e.g. for rates). |
iterations |
The number of iterations for the MCMC. |
burnin |
The number of iterations to burn before starting the MCMC. |
K |
The number of stepping stones. |
Returns the posterior samples for the parameters.
Sebastian Hoehna
Lartillot, N. and Philippe, H., 2006: Computing Bayes factors using thermodynamic integration. Systematic Biology, 55, 195
Baele et al., 2012: Improving the accuracy of demographic and molecular clock model comparison while accommodating phylogenetic uncertainty
Baele et al., 2013: Accurate Model Selection of Relaxed Molecular Clocks in Bayesian Phylogenetics
# load a test data set data(cettiidae) # convert the phylogeny into the branching times times <- as.numeric( branching.times(cettiidae) ) # construct a likelihood function taking in a vector of parameters likelihood <- function(params) { # We use the parameters as diversification rate and turnover rate. # Thus we need to transform first b <- params[1] + params[2] d <- params[2] lnl <- tess.likelihood(times,b,d,samplingProbability=1.0,log=TRUE) return (lnl) } # next, create the prior density functions prior_diversification <- function(x) { dexp(x,rate=0.1,log=TRUE) } prior_turnover <- function(x) { dexp(x,rate=0.1,log=TRUE) } priors <- c(prior_diversification,prior_turnover) # Note, the number of iterations, the burnin # and the number of stepping stones is too small here # and should be adapted for real analyses marginalLikelihood <- tess.pathSampling( likelihood, priors, runif(2,0,1), c(TRUE,TRUE), 10, 10, K=4)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.