High dimension of multivariate normal -- general question and machine precision issue

Any moderate sized covariance matrix has a good chance to become numerically problematic for some values of the structural parameters that Stan lands on during the leapfrom process. Basically, the advice is

  1. Parameterize things in terms of a Cholesky factor of a covariance matrix when possible
  2. If the error is due to numerical asymmetry, you can do something like R = 0.5 * (R + transpose(R)) after filling it.
  3. If the error is due to numerical indefiniteness, you can add a tiny positive constant to the diagonal of R after filling it or do something more complicated .
1 Like