# NOT RUN {
# generate a random tree
tree = generate_random_tree(list(birth_rate_intercept=1), max_tips=1000)$tree
# simulate a numeric trait under Brownian-motion
trait = simulate_bm_model(tree, diffusivity=1)
states = c(trait$tip_states,trait$node_states)
# calculate trait stats over time
results = get_trait_stats_over_time(tree, states, Ntimes=100)
# plot trait stats over time (mean +/- std)
M = results$means
S = results$stds
matplot(x=results$times,
y=matrix(c(M-S,M+S),ncol=2,byrow=FALSE),
main = "Simulated BM trait over time",
lty = 1, col="black",
type="l", xlab="time", ylab="mean +/- std")
# }
Run the code above in your browser using DataLab