Hi all,
I’m aiming to model binary species traits (presence = 1, absence = 0) as a function of some sampling variables. So I built a brms model adding to it a phylogenetic structure, and a Gaussian process, gp()
, to handle spatial autocorrelation. Here is my data, and the model:
full_model <- brms::brm(male_head | trials(1 + 0) ~
PC1 + PC2 + PC3 +
gp(x_coords, y_coords, k = 10, c = 5/4, iso = F, scale = FALSE) +
(1|gr(phylo, cov = covariance_matrix)),
data = data,
family = binomial(),
prior = prior,
data2 = list(covariance_matrix = covariance_matrix),
backend = "cmdstanr",
cores = 4,
control=list(adapt_delta = 0.999,
max_treedepth = 15,
step_size = 0.001),
thin = 10,
iter = 6000,
warmup = 2000,
seed = 123)
Priors consist of flat, uninformative values which I obtained through get_prior()
.
prior <- get_prior(male_hindwing | trials(1+0) ~
PC1 + PC2 + PC3,
data = data,
family = binomial())
So, each line of my data represents a observation with a binary response variable (i.e., a 1 or 0).
First of all, I am in doubt regarding the arguments to be used in trials()
. As I have species which have and species which do not have the traits I am modelling I thought I could use trials(1 + 0)
(I saw a vignette pointing it out, but I lost it). Is the syntax correct?
Additionally, the model is having a lot of divergent errors. I already used (1) different values for control parameters, (2) changed brms_algorithm from NUTS to HMC, and (3) reduced and scaled sampling variables, but no success, I keep getting several divergent transitions.
Any guess on how to deal with it?
My sessionInfo()
:
other attached packages:
[1] cmdstanr_0.5.3 mvSLOUCH_2.7.5 abind_1.4-5 phytools_1.2-0 maps_3.4.0 ape_5.6-2
[7] dplyr_1.0.10 brms_2.18.0 Rcpp_1.0.10