test = FALSE
if(test){
data(InfTemp)
# \donttest{
## Comparison between models
## require(phytools)
data(InfTemp)
set.seed(1)
tree <- pbtree(n=150, scale=67)
tree <- reorder(tree, "postorder")
beta = -0.2 # strengh and direction of the climatic effect
# The (latent) trait is simulated using the function "sim_t_env" (see also ?fit_t_env)
x <- sim_t_env(tree, param=c(0.1, beta), env_data=InfTemp, model="EnvExp", root.value=0,
step=0.001, plot=TRUE)
# Use the "threshState" function to simulate the discrete traits from the continuous one 'x'.
th <- sapply(x, threshState, thresholds = setNames(c(0,Inf), letters[1:2]))
# Fit the climatic model
clim_fit <- fit_t_thresh(tree, th, model="Clim", env_data=InfTemp)
plot(clim_fit)
# }
}
Run the code above in your browser using DataLab