diversitree
diversitree copied to clipboard
constrain behaves weirdly if doubly constraining a parameter:
Reported by @dwbapst:
library(diversitree)
pars <- c(0.1, 0.2, 0.03, 0.03, 0.01, 0.01)
set.seed(2)
phy <- tree.bisse(pars, max.t=60, x0=0)
lik <- make.bisse(phy, phy$tip.state)
lik.2 <- constrain(lik, lambda0 ~ lambda1, lambda0 ~ mu0)
last line generates warning:
Warning message:
In rels[i] <- res[[2]] : (symbol) object cannot be coerced to type 'list'
but the likelihood function doubly constrains lambda0
:
BiSSE likelihood function:
* Parameter vector takes 5 elements:
- lambda1, mu0, mu1, q01, q10
* Function constrained (original took 6 elements):
- lambda0 ~ lambda1
- lambda0 ~ mu0
* Function takes arguments (with defaults)
- pars: Parameter vector
- ...: Additional arguments to underlying function
- pars.only [FALSE]: Return full parameter vector?
* Phylogeny with 203 tips and 202 nodes
- Taxa: sp1, sp27, sp29, sp31, sp41, sp43, sp46, sp47, sp48, ...
* References:
- Maddison et al. (2007) doi:10.1080/10635150701607033
- FitzJohn et al. (2009) doi:10.1093/sysbio/syp067
R definition:
function (pars, ..., pars.only = FALSE)
lik.2(2:6, pars.only=TRUE)
gives
lambda0 lambda1 mu0 mu1 q01 q10
3 2 3 4 5 6