I wrote this generated quantity block :

```
generated quantities{
matrix[P,P] cov_lambda;
matrix[N,P] log_lik1;
vector[N*P] log_lik;
cov_lambda = multiply_lower_tri_self_transpose(lambda); //Create the covariance matrix
//Compute the likelihood for each observation
for(n in 1:N){
for(p in 1:P){
log_lik1[n,p] = poisson_lpmf(Y[n,p] | mu[n,p]);
}
}
log_lik = to_vector(log_lik1); //Tranform in a vector usable by loo package
}
```

but when I tried to compute loo :

covX_log_lik <- extract_log_lik(covX_stan, merge_chains = F)

covX_r_eff <- relative_eff(exp(covX_log_lik))

(covX_loo <- loo(covX_log_lik, r_eff = covX_r_eff))

I get this output :

`Computed from 3000 by 336 log-likelihood matrix`

```
Estimate SE
elpd_loo -779.0 47.2
p_loo 284.8 27.0
looic 1558.0 94.3
------
Monte Carlo SE of elpd_loo is NA.
Pareto k diagnostic values:
Count Pct. Min. n_eff
(-Inf, 0.5] (good) 124 36.9% 1
(0.5, 0.7] (ok) 75 22.3% 0
(0.7, 1] (bad) 90 26.8% 0
(1, Inf) (very bad) 47 14.0% 0
See help('pareto-k-diagnostic') for details.
There were 29 warnings (use warnings() to see them)
warnings()
Messages d'avis :
1: Some Pareto k diagnostic values are too high. See help('pareto-k-diagnostic') for details.
2: In log(z) : production de NaN
3: In log(z) : production de NaN
4: In log(z) : production de NaN
...
```

When I did what you suggested, that is

```
generated quantities{
matrix[P,P] cov_lambda;
matrix[N,P] log_lik1;
vector[N*P] log_lik;
cov_lambda = multiply_lower_tri_self_transpose(lambda); //Create the covariance matrix
//Compute the likelihood for each observation
for(n in 1:N){
for(p in 1:P){
log_lik1[n,p] = poisson_lpmf(Y[n,p] | mu[n]);
}
}
log_lik = to_vector(log_lik1); //Tranform in a vector usable by loo package
}
```

The loo computation was impossible, and returned NA only.