I am running a phylogenetic logistic regression using brm from brms package. My data consists on a categorical predictor (values 0, 1 and 2) and a binary response variabe (values 1 and 2) plus adding the effect of phylogeny as a predictor (1Ispecies). Here is my code:
options(scipen=999) #to avoid scientific notation
#setwd("C:/Users/User/OneDrive - ufabc.edu.br/Doutorado/Tentando de novo/Projeto_pos_FAPESP/Leonardo/Cap_2_Tese/")
setwd("C:\\Users\\leona\\OneDrive - ufabc.edu.br\\Doutorado\\Tentando de novo\\Projeto_pos_FAPESP\\Leonardo\\Cap_2_Tese")
data_neot<-read.csv("Visual_display_data.csv", sep = ";")
visdisp<-data.frame(data_neot$Scientific_Name, data_neot$VisDisp, data_neot$Activity.cat)
colnames(visdisp)<-c("species", "visdisp", "activity") #activity 0=nocturnal; 1=diurnal; 2=both
visdisp_data<-na.omit(visdisp)
row.names(visdisp_data)<-visdisp_data$species
visdisp_data<-visdisp_data[visdisp_data$activity != "" ,]
tree<-read.tree("C:\\Users\\leona\\OneDrive - ufabc.edu.br\\Doutorado\\Tentando de novo\\Projeto_pos_FAPESP\\Leonardo\\Cap_2_Tese\\teste_phylo_logist\\amph_shl_new_Posterior_7238.10000.trees")
class(tree)
namecheck_activity <- name.check(tree[[1]], visdisp_data) # checking which species
# are in the phylogeny but not in our data frame
trees_activity <- lapply(tree, drop.tip, namecheck_activity$tree_not_data) # pruning
# these species from all the 1,000 trees
class(trees_activity) <- "multiPhylo"
nrow(visdisp_data)
length(trees_activity[[1]]$tip.label) # number of tips in the phylogenic trees
if(any(is.ultrametric(trees_activity)) == FALSE) {
trees_activity <- lapply(trees_activity, chronoMPL)
class(trees_activity) <- "multiPhylo"
}
####Bayesian phylogenetic logistic regression####
div_prior<-get_prior(visdisp ~ activity + (1|species),
data = visdisp_data, family = bernoulli("logit"))
final_prior<-c(set_prior("student_t(3, 0, 2.5)", class = "sd", coef = "Intercept", group = "species"),
set_prior("student_t(3, 0, 2.5)", class = "sd", group = "species"),
set_prior("student_t(3, 0, 2.5)", class = "Intercept", group = "species"))
ntrees = 50
brms_activity <- rep(list(NA),ntrees) # list that will contain brm output for each tree
for(i in 1:ntrees){
# handling phylogeny to incorporate in brm
inv.phylo <- inverseA(trees_activity[[i]], nodes = "TIPS", scale = TRUE)
A <- solve(inv.phylo$Ainv)
rownames(A) <- rownames(inv.phylo$Ainv)
brms_activity[[i]] <- brm(
visdisp ~ activity + (1|species),
data = visdisp_data, sample_prior = "yes", prior = div_prior, family = bernoulli("logit"),
cov_ranef = list(species = A), # incorporating phylogeny
chains = 6, cores = 6, iter = 3000, warmup = 1000,
refresh = 0, control = list(max_treedepth = 21, adapt_delta=0.9999999999999999, stepsize = 0.0001)
)
}
However, I am having several warnings in the output. The warnings are:
Mensagens de aviso:
1: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
2: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
3: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
4: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
5: There were 1 divergent transitions after warmup. See
https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
to find out why this is a problem and how to eliminate them.
6: Examine the pairs() plot to diagnose sampling problems
7: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
8: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
9: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
10: There were 6 divergent transitions after warmup. See
https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
to find out why this is a problem and how to eliminate them.
11: Examine the pairs() plot to diagnose sampling problems
12: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#bulk-ess
13: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
14: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
15: The largest R-hat is 1.07, indicating chains have not mixed.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#r-hat
16: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#bulk-ess
17: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
18: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
19: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
20: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
21: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
22: There were 2 divergent transitions after warmup. See
https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
to find out why this is a problem and how to eliminate them.
23: Examine the pairs() plot to diagnose sampling problems
24: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
25: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
26: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
27: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
28: There were 1 divergent transitions after warmup. See
https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
to find out why this is a problem and how to eliminate them.
29: Examine the pairs() plot to diagnose sampling problems
30: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#bulk-ess
31: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
32: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
33: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#bulk-ess
34: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
35: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
36: There were 1 divergent transitions after warmup. See
https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
to find out why this is a problem and how to eliminate them.
37: Examine the pairs() plot to diagnose sampling problems
38: Bulk Effective Samples Size (ESS) is too low, indicating posterior means and medians may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#bulk-ess
39: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
40: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
41: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
42: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
43: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
44: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
45: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
46: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
47: Tail Effective Samples Size (ESS) is too low, indicating posterior variances and tail quantiles may be unreliable.
Running the chains for more iterations may help. See
https://mc-stan.org/misc/warnings.html#tail-ess
48: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
49: Argument 'cov_ranef' is deprecated and will be removed in the future. Please use argument 'cov' in function 'gr' instead.
50: There were 1 divergent transitions after warmup. See
https://mc-stan.org/misc/warnings.html#divergent-transitions-after-warmup
to find out why this is a problem and how to eliminate them.
As you guys can see, I put adapt_delta in its max value, changed iterations number, max_treedepth and stepsize values, and I got the warnings. What more should I do?