# Experiment for Latent Gaussian Models

**URL:** <https://discourse.mc-stan.org/t/experiment-for-latent-gaussian-models/5874>\
**Category:** Modeling\
**Created:** [October 4, 2018, 2:35pm UTC](https://discourse.mc-stan.org/t/experiment-for-latent-gaussian-models/5874 "2018-10-04T14:35:15Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![avehtari](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/avehtari/32/5935_2.png) [@avehtari](https://discourse.mc-stan.org/u/avehtari)\
**Post date:** [October 4, 2018, 3:54pm UTC](https://discourse.mc-stan.org/t/experiment-for-latent-gaussian-models/5874/2 "2018-10-04T15:54:49Z")

</div>

For the effective sample size experiments [N\_eff BDA3 vs. Stan](https://discourse.mc-stan.org/t/n-eff-bda3-vs-stan/2608/21?u=avehtari)  
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

---

_[View the full topic](https://discourse.mc-stan.org/t/experiment-for-latent-gaussian-models/5874)._
