I have a Stan model using ssmodels-in-stan that worked fine with ssm_constant_lpdf(), but when I switched to ssm_lpdf() I started getting the error "Rejecting initial value: Error evaluating the log probability at the initial value." Some experimentation showed that it was in fact the call to ssm_lpdf() that is the problem. Digging in further, the problem appears to be the line
K = ssm_update_K(P, T_t, Z_t, Finv);
near the end of the function. The definition of ssm_update_K looks like this:
matrix ssm_update_k(matrix P, matrix Z, matrix T, matrix Finv) {
matrix[cols(Z), rows(Z)] K;
K = T * P * Z' * Finv;
return K;
}
So you have Z and T swapped in the call to ssm_update_K, leading to non-conforming matrices in the matrix multiply.
I have a Stan model using ssmodels-in-stan that worked fine with ssm_constant_lpdf(), but when I switched to ssm_lpdf() I started getting the error "Rejecting initial value: Error evaluating the log probability at the initial value." Some experimentation showed that it was in fact the call to ssm_lpdf() that is the problem. Digging in further, the problem appears to be the line
near the end of the function. The definition of ssm_update_K looks like this:
So you have Z and T swapped in the call to ssm_update_K, leading to non-conforming matrices in the matrix multiply.