4
$\begingroup$

How do I fit a bayesian multilevel model with with AR(1) correlation structure?

I am trying to teach myself bayesian modelling and I am wondering how you could specify a multilevel model with an AR(1) correlation structure.

e.g how do i get the equivalent from nlme using either JAGS or stan?

lme(y ~ time + x, random=~time|subject, corr=corAR1())
$\endgroup$
2
$\begingroup$

I never tried it my self, so at best you should trust, but verify.

I don't know the syntax of nlme (I use lmer4 in R), so I'll guess some stuff here.

Assuming your (non hierarchical) model is something like:

$y_{i,t} \sim N(a+b*y_{i,t-1} + c*t_{i} + d*x_{i}, \sigma^{2})$

And the hierarchical version (grouping by subject) would be:

$y_{i,t} \sim N(a[i] +b*y_{i,t-1} + c*t_{i} + d*x_{i}, \sigma^{2})$

$ a[i] \sim N( \mu, \sigma_{a}^{2})$

Now just write your priors and hyperpriors and program it in Jags or Stan.

I suggest you to use tsbugs package. It will help you to create code to winbugs.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.