Test for nan

I have this complaint during execution

Informational Message: The current Metropolis proposal is about to be rejected because of the following issue:
Exception: Exception: multiply: A[7] is nan, but must not be nan! (in ‘/Users/me/workspace/myproject/mymodel.stan’ at line 174)

line 174 is
middleMatrix = iQt(xi, beta, x_array[t-1]) * phi(visit_array[t], C_array[t], alpha_array, gamma_array, z_array[t], eta_array);

there is no A[7]. Both iQt and phi return matrix[3,3]

I tried print out iQt and phi values when its nan, but neither is_nan(iQt) nor iQt == nan (or Nan) works.

Any idea what is A[7] and how to test for nan for matrices?

The 7th element of the matrix on the left being multiplied and you have to test for that using is_nan with a for loop over the elements of the matrix. Also, there should be a more specific line number pointing to multiplication inside your iQt function.

1 Like

thank you. resolved!