# CFA model cannot recover simulated values

**URL:** <https://discourse.mc-stan.org/t/cfa-model-cannot-recover-simulated-values/27857>\
**Category:** Modeling\
**Tags:** fitting-issues\
**Created:** [June 16, 2022, 9:50pm UTC](https://discourse.mc-stan.org/t/cfa-model-cannot-recover-simulated-values/27857 "2022-06-16T21:50:38Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![edm](https://avatars.discourse-cdn.com/v4/letter/e/f08c70/32.png) [@edm](https://discourse.mc-stan.org/u/edm)\
**Post date:** [June 19, 2022, 8:35pm UTC](https://discourse.mc-stan.org/t/cfa-model-cannot-recover-simulated-values/27857/4 "2022-06-19T20:35:22Z")

</div>

I don’t know of a Bayesian NMF implementation in Stan.

For PSIS-LOO and bad Pareto k, I typically avoid the conditional likelihood and use marginal instead. If you wanted to use conditional likelihood, I think the recommendation would be to set up your own cross-validation. Some more details are [here](https://avehtari.github.io/modelselection/index.html) (especially see the FAQ).

For parameterizing the multivariate normal via mean and covariance matrix, I think the code below will do it. Mu and Sigma are the multivariate normal parameters; xbar and S are the observed mean and covariance matrix; N is number of observations; p is the dimension of the multivariate normal:

```nohighlight
out = -.5 * N * ( sum( inverse_spd(Sigma) .* (S + (xbar - Mu) * (xbar - Mu)') ) + log_determinant(Sigma) + p * log(2 * pi()) );

```

---

_[View the full topic](https://discourse.mc-stan.org/t/cfa-model-cannot-recover-simulated-values/27857)._
