Experiment for Latent Gaussian Models

For the effective sample size experiments N_eff BDA3 vs. Stan
I used simple version:

transformed data {
  vector[D] zero = rep_vector(0.0, D);
  cov_matrix[D] S;
  cholesky_factor_cov[D] L;
  for (i in 1:D) {
    for (j in 1:(i-1)) {
      S[i,j]=s;
      S[j,i]=s;
    }
    S[i,i]=1.0;
  }
  L = cholesky_decompose(S);
}

but what you propose would work, too. I guess you use LKJ construction if you want to generate random matrices, or you could use cov_exp_quad with random x and varying lengthscale (increasing lengthscale increases correlation)

matrix[N, N] cov =   cov_exp_quad(X, 1.0, lengthscale) + diag_matrix(rep_vector(square(sigma), N));

with some small sigma