Underestimating correlation coefficients with LKJ prior

The elements above the diagonal of a Cholesky factor are fixed to zero rather than being random variables, so the Rhat is indeed not defined for them. This thread was about the elements below the diagonal.

Oh great! I did not think enough. Thank you very much!

“It’s not important what we cover in the class; it’s important what you discover.”

VICTOR WEISSKOPF

Candidat à la maîtrise en sciences de l’environnement

Chargé de cours : “Taxonomie des plantes vasculaires”

Chaire de Recherche du Canada en Intégrité Écologique

Centre de recherche sur les interactions bassins versants-écosystèmes aquatiques

Université du Québec à Trois-Rivières

3351 boul. des Forges, CP 500

Trois-Rivières, QC, G9A 5H7

Canada

Téléphone: 819-376-5011 poste 3373

I think that’s the same function, only without a restriction to lower triangular. The lower triangular version should use less memory.

We’re not only improving the syntax, we’re also fixing some of the bugs with supressed warning messages.

Sorry to resurrect this old thread but is there a reason that this

was recommended instead of

  matrix[N, N] C
     = multiply_lower_tri_self_transpose(C_input);
  {
    real p_3_p1 = p[3] + 1;
    for (n in 1:N)  C[n, n] += p_3_p1;
    for (n in 1:N) {
      for (m in 1:n-1) {
          C[n, m] += p[3];
          C[m, n] = C[n, m];
   // or  C[m, n] += p[3];
    }
 }

Hmm I think you could do either thing. I didn’t read the thread – just going by the code you posted.

You’re trying to add a constant to the non-diagonal part of a matrix, so I guess there are multiple ways to do that.

Matrices in Stan are column major so I think the best way to write it would probably be with the n loop as the innermost loop. If there’s a Cholesky anywhere that’s gonna be more expensive so many it doesn’t matter.

It’s always good to make new threads with stuff like this. You can just reference the old thread in your new post.

1 Like