knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.align = "center", eval = TRUE )
library(zazou) library(ape) set.seed(42)
tree <- read.tree(text = "(((A:1,B:1):1,C:2):1,(D:1,E:1):2);") true_shifts <- c(0, -3, 0, 0, 0, 0, -2, 0) alphaOU <- 1 lambda <- 0.1
(true_zscores <- incidence_matrix(tree) %*% true_shifts)
observed_zscores <- simu_zscores(tree = tree, shifts = true_shifts, alphaOU = 1, graph = TRUE) observed_zscores
mthd1 <- estimate_shifts(zscores = observed_zscores, lambda = lambda, tree = tree, alphaOU = alphaOU, method = "L-BFGS-B") mthd1 plot(mthd1)
mthd2 <- estimate_shifts(zscores = observed_zscores, lambda = lambda, tree = tree, alphaOU = alphaOU, method = "lasso") mthd2 plot(mthd2)
true_shifts mthd1$shifts_est mthd2$shifts_est
t(true_zscores) mthd1$zscores_est mthd2$zscores_est
mthd1$objective_value mthd2$objective_value
mthd1$optim_info mthd2$optim_info
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.