I am working on a mixture model with family-level random effects. I would like to parameterize the random effects as independent across families each with a covariance matrix parameterized using the kernel trick (Gaussian Process Regression). Each family has a distance matrix \mathbf{D}_j (of potentially differing dimension) that is converted into the covariance matrix with a Gaussian Kernel: \mathbf{h}_j\sim\mathcal{N}\left(\mathbf{0}, \tau\exp\left[-\rho\mathbf{D}_j\right]\right), where the exp() is applied element-wise.

I know that ragged arrays have yet to be implemented (https://github.com/stan-dev/stan/wiki/Ragged-array-spec) but in R, we could simply create a list called D where D[[j]] accesses \mathbf{D}_j. Does anyone have ideas about how to (simply) implement something like this in RStan without using very large, sparse matrices? All I need is to define \mathbf{K}_j=\exp\left[-\rho\mathbf{D}_j\right] in the transformed parameters block for learning \rho, which requires a way of easily constructing/accessing each \mathbf{D}_j.