I’ve been working on fitting some multilevel models using brms and I can’t seem to shake the last few divergences, despite my best efforts. I’m trying to model the effects of two particular treatments on aphid population growth over time. I’m trying to predict aphid population size at t=2 using the treatment and the population size at t=1, with varying effects across 3 trial blocks (30 total reps per block).
adapt_delta to > .9999 and
max_treedepth to 30, tweaked my priors a bunch (I’ve tried Student’s t, cauchy, and normal priors with lots of different widths), and I still get 2-8 diversions each time. The model still runs pretty quickly on my machine, even with the high control values. Since brms uses the non-centered parameterization by default, I don’t think there’s anything I can do on that front.
I’ve examined the pairs plots and I can’t seem to find any really strong patterns for the divergent iterations, but I’ve included the plot here in case it’s helpful.
Here is the model as I’ve written it in R:
model_3.1 <- brm( data = data, family = negbinomial, aphid_total_count_2 ~ 1 + treatment + aphid_total_count_1 + (1 + treatment + aphid_total_count_1 | trial_number), prior = c( set_prior("normal(3,1)", class = "Intercept"), set_prior("normal(0.5,5)", class = "b", coef = "aphid_total_count_1"), set_prior("normal(0,.5)", class = "b"), set_prior("cauchy(0,.1)", class = "sd"), set_prior("lkj(1)", class = "cor") ), iter = 5000, warmup = 1000, chains = 3, cores = future::availableCores(), control = list(adapt_delta = 0.9999999999, max_treedepth = 40) )
Here are the data and the little bit of code to read and clean the data for use in the model:
APHIS_Fall_2018_Trials_2_3_4.csv (2.5 KB)
data <- read_csv("raw_data/APHIS_Fall_2018_Trials_2_3_4.csv", skip = 1) data$trial_number <- as.factor(data$trial_number)
I’ve searched high and low on discourse, the google group, the manual, etc. and I’ve found lots of useful information, but nothing quite seems to work. Unfortunately I’m still learning to write straight Stan, so some of the advice was a bit over my head. I’m hoping perhaps I’m missing something obvious, and I’d really like to improve my application of these types of multilevel models in general. Thank you!