Temporal Autocorrelation using brms

Hi there,
I really hope that someone can help me out.

I want to account for temporal autocorrelation given by the year of sampling within tree different groups of my data. I have coded my groups due to dummy variables.
I am new to brms ealier I have been using the rethinking.

I have various sampling for each year and group.

I tried looking into using arma, but I am obviously coding this wrong. I tried to add year as the time variable in the arma argument. I am also trying to add my groups of interest into the argument, but its wrong to I suppose.

My wrong model looks like this

m1<-
brm(data=dat,
family=gaussian,
bf(Y ~ X + Gr2 + Gr3 + arma(time = Year, gr = Gr2:G3)),
prior=c(prior(normal(0,10), class=b), prior(cauchy(0,1), class=sigma)),
iter=2000, warmup=1000, chains=3, cores=1)

I get this error when I run my model.
Error: Time points within groups must be unique.

Thanks a lot in advance,
Signe

Hi,
sorry for not getting to you earlier - did you manage to resolve this in the meantime?

Unfortunatley, I don’t think I can help you much without seeing the data. I think that brms expect you to have only one observation for each time and group combination, so if you observe multiple time series in each category, you’ll need to have the gr argument to be different for each time series.

Also note that brms will happily do the dummy coding for you, so if you have data$Gr = c("A", "B", "A", "C", ...) then you can write bf(Y ~ Gr) and Gr will be dummy coded by brms.

Best of luck with your model!