# Sampling statement for cfa on correlation matrix

**URL:** <https://discourse.mc-stan.org/t/sampling-statement-for-cfa-on-correlation-matrix/3978>\
**Category:** Modeling\
**Created:** [April 25, 2018, 9:32am UTC](https://discourse.mc-stan.org/t/sampling-statement-for-cfa-on-correlation-matrix/3978 "2018-04-25T09:32:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Felix\_Fischer](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/felix_fischer/32/5787_2.png) [@Felix\_Fischer](https://discourse.mc-stan.org/u/Felix_Fischer)\
**Post date:** [April 25, 2018, 9:32am UTC](https://discourse.mc-stan.org/t/sampling-statement-for-cfa-on-correlation-matrix/3978/1 "2018-04-25T09:32:31Z")

</div>

Hi guys,

i am trying to model a confirmatory factor analysis on a correlation matrix. Therefore, i set up matrices and priors for loadings, factor correlations and variances and use those to calculate a model-implied correlation matrix, much like in ML estimation:

correlations\_{implied} = loadings \* correlations\_{factor} \* loadings' + variances

I struggle then to correctly set up a sampling statement. I do something like this:

```stan
model {
  observed_correlations ~ normal(implied_correlations, 0.1);
} 

```

This sampling statement seems to work, but i am concerned about the 0.1, which is just an arbitrary value i chose. Is there a more reasonable way to do this?

best, Felix

---

<div class="post-metadata">

**Author:** ![bbbales2](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bbbales2/32/77_2.png) [@bbbales2](https://discourse.mc-stan.org/u/bbbales2)\
**Post date:** [April 25, 2018, 4:42pm UTC](https://discourse.mc-stan.org/t/sampling-statement-for-cfa-on-correlation-matrix/3978/2 "2018-04-25T16:42:15Z")

</div>

Factor analysis models get pretty involved. There was a thread a few days ago with someone setting one up: [Help with factor analysis (latent variable model)](http://discourse.mc-stan.org/t/help-with-factor-analysis-latent-variable-model/3923) . It sounds like everything got worked out, and the code is pretty clean and well commented, so I’d recommend you have a look there and see if it gives you some clues on how to goo about building your model.

---

<div class="post-metadata">

**Author:** ![Felix\_Fischer](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/felix_fischer/32/5787_2.png) [@Felix\_Fischer](https://discourse.mc-stan.org/u/Felix_Fischer)\
**Post date:** [April 27, 2018, 6:34am UTC](https://discourse.mc-stan.org/t/sampling-statement-for-cfa-on-correlation-matrix/3978/3 "2018-04-27T06:34:49Z")

</div>

Thanks, that helped!

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [May 22, 2018, 8:30pm UTC](https://discourse.mc-stan.org/t/sampling-statement-for-cfa-on-correlation-matrix/3978/4 "2018-05-22T20:30:52Z")

</div>

> [@Felix\_Fischer](#):
>
> i am concerned about the 0.1, which is just an arbitrary value i chose. Is there a more reasonable way to do this?

I don’t know about this model in particular, but in cases like the IRT model you just need to establish a fixed scale—it doesn’t matter what it is. Here, the loadings are probably providing the scaling.
