hyper_matrix0: Function to build a matrix, used in creating the A and B...

Description Usage Arguments Author(s) Examples

View source: R/mbd_loglik_utils.R

Description

Function to build a matrix, used in creating the A and B operators. It produces the structure q ^ (m - n) * (1 - q) ^ (k + 2 * n-m) * sum_j 2 ^ j choose(k, j) * choose(n, m - n - j)

Usage

1
hyper_matrix0(n_species, k, q)

Arguments

n_species

number of species.

k

the number of visible species in the phylogeny at a given time.

q

the single-lineage speciation probability at a triggered event.

Author(s)

Hanno Hildenbrandt, adapted by Richel J.C. Bilderbeek

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
  m <- mbd::hyper_matrix0(n_species = 2, k = 2, q = 0.1)
  testthat::expect_equal(m[1, 1], 0.81)
  testthat::expect_equal(m[1, 2], 0.00)
  testthat::expect_equal(m[1, 3], 0.00)
  testthat::expect_equal(m[2, 1], 0.36)
  testthat::expect_equal(m[2, 2], 0.729)
  testthat::expect_equal(m[2, 3], 0.00)
  testthat::expect_equal(m[3, 1], 0.04)
  testthat::expect_equal(m[3, 2], 0.405)
  testthat::expect_equal(m[3, 3], 0.6561)

Giappo/mbd documentation built on March 3, 2020, 3:36 a.m.