Dear all,

I would like to develop a stan-model which I previously implemented as a linear mixed effects model using the nlme package in R. I have longitudinal data with up to `n_k`

datapoints from `k`

subjects. Means should be random among subjects and relationships between the individual points should be described via a multivariate normal distribution with correlations depending on the distance (in time) between the datapoints.

So basically the model would be a mixed model with random intercepts and spatial correlation. It is slightly more complicated since the correlation should further depend on covariates, so ideally I would define a function which sets up the covariance matrix for each subject individually (varying number of points per subject, different times and covariates) depending on a small set of estimated variance/covariance parameters. For the nlme package, I wrote a function which generates the subject-wise covariance matrix, but I don’t really have an idea how to do this with stan. Before extensive trial and error, is this generally feasible with stan and are there any tutorials on this matter I didn’t come across yet?

Thanks a lot in advance

Max