4

I'm running a zero-inflated, mixed-effects negative binomial model with the glmmTMB package in R.

My current format:

mod1 = glmmTMB(count ~ a + b + offset(c) + (1|d) + (1|e), ziformula= ~a, data = dat, family = nbinom2(link = 'log'))

I have noticed signs of temporal autocorrelation between count and variable "d" (which are individual years for a time-series dataset). Despite reading Kasper Kristensen's vignette, I'm still struggling to write a covariance structure using AR(1) ar1 . Do any of you have any suggestions please?

I understand the general structure is struc(terms|group). I'm assuming "d", or years, will be the terms variable, but I'm unsure what I should use for group? In other examples of AR(1) structure, I've seen people group only by year (e.g., form=~year).

Thanks, Andrew

Andrew
  • 41
  • 3

1 Answers1

3

you've probably found an answer by now but for anyone who is trying to ask a similar question I've found some answers in this updated version of the vignette you mentioned "Covariance structures with glmmTMB" (Kasper Kristensen, 2020-03-15).

For your particular problem, I would use a unique identifier for each group within each individual year, assuming there is an identifiable group in your dataset. An example might be subjects that are analyzed for each year: (1|subject) + ar1(year + 0|subject), where year and subject are factor variables.

James R.
  • 73
  • 1
  • 8