You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can apply the sqrt function elementwise to a matrix, but Stan Math does not have a function to take the (symmetric) square root of a positive definite matrix (or its inverse), defined as V * diag_matrix(sqrt(v)) * V' where V is a matrix of eigenvectors and v is a vector of eigenvalues. In the case of the inverse square root of a matrix, there is a diag_matrix(inv_sqrt(v)) in the middle. Eigen already calculates these, so it is just a matter of exposing them and working through the Jacobians.
#1144)
Rearranged some includes in stan/math/rev/mat.hpp to get rid of some type traits errors. Not sure why these were moved around. Might need moved back.
I'd like to boost the priority on this one and I suggest we name the function matrix_sqrt(). Sarah Heaps has an elegant unconstrained parameterization of stationary parameters for a vector autoregressive (VAR) model. It uses matrix square root. She sent along the code she was using for it in Stan, without the new tuple feature
Description
You can apply the
sqrt
function elementwise to a matrix, but Stan Math does not have a function to take the (symmetric) square root of a positive definite matrix (or its inverse), defined asV * diag_matrix(sqrt(v)) * V'
whereV
is a matrix of eigenvectors andv
is a vector of eigenvalues. In the case of the inverse square root of a matrix, there is adiag_matrix(inv_sqrt(v))
in the middle. Eigen already calculates these, so it is just a matter of exposing them and working through the Jacobians.Example
[Note: The
sqrt_spd
andinv_sqrt_spd
functions do not exist in Stan yet.]Expected Output
Satisfies inequality restrictions on
check
.Current Version:
v2.33
The text was updated successfully, but these errors were encountered: