Function_ComputeDistances_MultiVariateBM: Function_ComputeDistances_MultiVariateBM: function to compute...

Description Usage Arguments Value Examples

View source: R/Function_ComputeDistances_MultiVariateBM.R

Description

This function returns a vector containing the Hellinger and KL distances between two tree models

Usage

1
Function_ComputeDistances_MultiVariateBM(list.Model_01, list.Model_02)

Arguments

list.Model_01

List containing the following (1) handle.Phylogeny, (2) vector.Z = vector of mean (ancestral) state values, and (3) vector.Model_01_Theta = vector containing relevant parameters for the models, and (4) matrix.C = matrix containing the across trait variance/covariances

list.Model_02

List containing the following (1) handle.Phylogeny, (3) vector.Z = vector of mean (ancestral) state values, and (3) vector.Model_02_Theta = vector containing relevant parameters for the models, and (4) matrix.C = matrix containing the across trait variance/covariances

Value

vector.Distances Vector containing the distances computed between the two focal tree models

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
################
# Load depends #
################
library(ape)
library(geiger)
library(gaussDiff)

############################################################################################
# Specifity example tree (Fig. 8, Felsenstein 1985) used for demonstrating model distances #
############################################################################################
string.Figure01_Felsenstein1985_Tree <- "(((Species_7:1.635983031,Species_8:0.8079384444):1.801052391,(Species_6:0.4510394335,Species_5:1.208543249):0.4146682462):0.4476024657,((Species_4:0.9434278477,Species_3:0.2480806489):2.642993143,(Species_2:2.588686978,Species_1:0.908678702):0.3223280154):1.399150111):1;"
handle.Figure01_Felsenstein1985_Tree <- read.tree(text = string.Figure01_Felsenstein1985_Tree)

#################################################
# Set a vector containing parameters for Models #
#################################################
vector.Model_01_Theta <- c(1)
names(vector.Model_01_Theta) <- c("Sig2")
vector.Model_02_Theta <- c(1)
names(vector.Model_02_Theta) <- c("Sig2")

matrix.Model_01_C <- matrix(nrow = 2, ncol = 2)
matrix.Model_01_C[1,] <- c(1, 0.5)
matrix.Model_01_C[2,] <- c(0.5, 1)

matrix.Model_02_C <- matrix.Model_01_C
matrix.Model_02_C[1,2] <- matrix.Model_02_C[2,1] <- 0.75

#####################
# Build Model lists #
#####################

list.Model_01 <- list(handle.Phylogeny = handle.Figure01_Felsenstein1985_Tree,
                      vector.Z = rep(0, 2*length(handle.Figure01_Felsenstein1985_Tree$tip.label)),
                      vector.Theta = vector.Model_01_Theta,
                      matrix.C =  matrix.Model_01_C)

list.Model_02 <- list(handle.Phylogeny = handle.Figure01_Felsenstein1985_Tree,
                      vector.Z = rep(0, 2*length(handle.Figure01_Felsenstein1985_Tree$tip.label)),
                      vector.Theta = vector.Model_02_Theta,
                      matrix.C =  matrix.Model_02_C)

#####################
# Compute distances #
#####################
Function_ComputeDistances_MultiVariateBM(list.Model_01 = list.Model_01, list.Model_02 = list.Model_02)

radamsRHA/PRDATR documentation built on Dec. 25, 2021, 11:44 a.m.