set.seed(5)
phy <- ape::rphylo(n = 4, birth = 1, death = 0)
traits <- c(0, 1, 1, 0)
params <- secsse::id_paramPos(c(0, 1), 2)
params[[1]][] <- c(0.2, 0.2, 0.1, 0.1)
params[[2]][] <- 0.0
params[[3]][, ] <- 0.1
diag(params[[3]]) <- NA
# Thus, we have for both, rates
# 0A, 1A, 0B and 1B. If we are interested in the posterior probability of
# trait 0,we have to provide a helper function that sums the probabilities of
# 0A and 0B, e.g.:
helper_function <- function(x) {
return(sum(x[c(5, 7)]) / sum(x)) # normalized by total sum, just in case.
}
out_plot <- plot_state_exact(parameters = params,
phy = phy,
traits = traits,
num_concealed_states = 2,
sampling_fraction = c(1, 1),
num_steps = 10,
prob_func = helper_function)
Run the code above in your browser using DataLab