Low ESS and high autocorrelation in negative binomial regression with random intercepts

Hi, I’m trying to fit some firing rate data with a brms model. I model the firing rates from the predictors using a negative binomial regression with random intercepts for cell. The model seem to fit mostly fine, within a reasonable time and no divergent transitions, however, I do get warnings about low bulk and tail effective sample size (ESS). Specifically, I’m getting very low ESS for the global intercept and the sd of the random intercepts (the other parameters are fine).

I’ve looked at pairs plots in shinystan and there doesn’t seem to be strong correlation between any pair of the parameters. However, the two troublesome parameters (Intercept and sd of random intercepts) do have high autocorrelation.

I tried fiddling around with the brm() controls and setting somewhat more informative priors, however, that didn’t really help. The only thing I found that helps is setting the priors for Intercept and sd of intercepts very narrow, centered on the previously estimated posterior means (see the model code below). After that, the model samples well and I get good ESS for all parameters.

Code for the model with the very strong priors that results in good ESS:

fit1 <- brm( FR ~ 1 + Cat + CorInc + (1 | Cell), data = df, family = negbinomial(),
             #control = list(adapt_delta = 0.9,  max_treedepth = 10), 
             prior = c(prior(normal(-1.24, 0.01), class = 'Intercept'),
                       prior(normal(1.32, 0.01), class = 'sd', coef = 'Intercept', group = 'Cell')),
             iter = 1000, chains = 4, cores = 4)

Any idea of what could be the problem and how to fix it? Thanks!

1 Like

There are a few possibilities, depending on how exactly do your data look like. Could you share (a subset of ) the data? How many observations do you have per cell?

Just to re-check - did you look at overall Intercept vs. a few Cell-specific intercepts? (I’ve seen those be troublesome in a few models).

That unfortunately almost surely introduces a bias in your inferences and is thus not recommended.

Hope we can get this resolved quickly.

Hi Martin,

Thanks very much for the help! I’ve attached a small subset of the data with ten cells worth of firing rates. The number of observations per cell varies quite a lot. For some cells there are up to 140 observations, for others there are only a few observations. There are particuarlly small numbers of observations for incorrect trials (see column 4: 1 = correct, 2 = incorrect). Perhaps this could introduce problems when fitting cell specific incercepts.

I have checked the overall intercept vs. some of the cell specific intercepts in shinystan and there is quite a lot of variability between cell specific intercepts and the overall incercept: e.g., overall intercept mean: -1.22, cell 1: -0.6, cell 2: 0.2, cell 3: 3.15, cell 4: 1.18.

example_data.txt (7.3 KB)

cheers :)

With such a big range of measurements per cell I fear you’ll need to use “centered” parametrisation for some of the intercepts and “non-centered” for others (see the discussion of pathologies at https://betanalpha.github.io/assets/case_studies/hierarchical_modeling.html) unfortunately that is currently not supported in brms (brms uses non-centered parametrization everywhere). Just to be sure, could you share the pairs (or bayesplot::mcmc.pairs) plot including overall intercept, SD of the random intercept and intercept for cell with small no. of observations and one with many observations?

1 Like