Brms: fitting negative binomial model with an AR-correlation structure

I’m fitting a GAMM in brms (vers. 2.15.0).
My response variable is counts in permanent plots over time. The model is clearly overdispersed with a Poisson distribution, thus I’m using a negative binomial distribution.

The model fits fine, but due to the repeated measures in permanent plots, I have an issue with temporal autocorrelation. Therefore, I have included an AR(1) correlation structure in the model. However, apparently it is causing some fitting troubles. It seems like brms has troubles estimating the shape parameter in the negative binomal distribution when an AR (or ARMA) correlation structure is included in the model.

Any advises what to do?

brm(counts ~ s(time) + (1|plot) + ar(time = time, gr = plot, p = 1, cov = TRUE),
data = mydata,
family = negbinomial(link = "log"))
1 Like

Hi, sorry for not getting to you earlier.

AR models with non-gaussian families are generally prone to problems as they do not have nice closed forms and if I remember correctly, brms will introduce a ton of nuisance paramters to model the autoregression structure (if you can read Stan code, you’ll see this when inspecting the result of make_stancode). This can make the model badly behaved for all sorts of reasons.

In your case, I would expect that a possible issue is the combination of s(time) and the AR term which both account for some sort of smooth variation over time and so it is likely that their contributions are mostly interchangeable learning both at the same time is not possible (i.e. the model is only weakly identified). So I would try some similar but simpler models such as:

counts ~ s(time) + (1|plot)
counts ~ (1|plot) +  ar(time = time, p = 1, cov = TRUE)
counts ~ (1|plot) +  ar(time = time, gr = plot, p = 1, cov = TRUE)
counts ~ s(time) + (1|plot) +  ar(time = time, p = 1, cov = TRUE)

and see where the problems start to appear.

Best of luck with your model!