Convergence problems with factor loadings in multivariante autoregressive model

Take a look at this post Help with factor analysis (latent variable model) and the latent factor model in the Stan manual. That post references @rfarouni blog http://rfarouni.github.io/2015-04-26-fa/ which has a lot more detail.

That post shows how to write the multi normal in terms of cholesky factors. Also you can remove some of the double loops by vectorization such as

// your formulation
  for (s in 1:sp)
      for (l in 1:nf)
          phi[s, l] ~ gamma(3.0 / 2.0, 3.0 / 2.0);

// faster, this takes phi[s] as a vector length nf and places
// the gamma prior on each element of the vector
  for (s in 1:sp)
  phi[s] ~ gamma(3.0 / 2.0, 3.0 / 2.0);
1 Like