Dear Stan Forum,

I encountered a weird issue about a symmetric matrix reported not being symmetric for the covariance matrix of multi_normal_lpdf.

The exact error message is the following:

“Rejecting initial value:

Error evaluating the log probability at the initial value.

Exception: Exception: multi_normal_lpdf: Covariance matrix is not symmetric. Covariance matrix[1,17] = 0.000174503, but Covariance matrix[17,1] = 0.000255977 (in ‘/Users/…/model.stan’, line 21, column 4 to column 142) (in ‘/Users/…/model.stan’, line 83, column 4 to line 84, column 86)”

Line 21 mentioned in the message calls the multi_normal_lpdf function, which relies on the covariance matrix QtMOmegaMtQ:

```
multi_normal_lpdf(Qtrating_benchmarked_i | x*QtMmu_C, QtMOmegaMtQ)
```

The covariance matrix was defined in line 19:

```
matrix[num_calibration-d,num_calibration-d] QtMOmegaMtQ = (QtM * QtM') *(x^2 * sigma_epsilon^2+sigma_eta^2);
```

The above covariance matrix is symmetric because it is of the form “matrix * matrix’ * scalar”.

Lines 83 and 84 mentioned in the message are about the 1-dimensional integration over a function that calls multi_normal_lpdf.

I attached the minimal code for replicating this error message. To run the code, first compile model.stan and then run `bash sampling.sh`

Any help is greatly appreciated! Thank you very much!

model.stan (4.1 KB)

(Uploading .json data file and .sh script file seems not allowed. You can find them in here: Dropbox - test - Simplify your life)