Motivation: I'm writing a state estimator in MATLAB (the unscented Kalman filter), which calls for the update of the (upper-triangular) square-root of a covariance matrix $S$ at every iteration (that is, for a covariance matrix $P$, it is true that $P=SS^{T}$). In order for me to perform the requisite calculations, I need to do a Rank-1 Cholesky Update and Downdate using MATLAB's cholupdate
function.
Problem: Unfortunately, during the course of the iterations, this matrix $S$ can sometimes lose positive definiteness. The Cholesky downdate fails on non-PD matrices.
My question is: are there any simple and reliable ways in MATLAB to make $S$ positive-definite?
(or more generally, is there a good way of making any given covariance $X$ matrix positive-definite?)
Notes:
- $S$ is full rank
- I've tried the eigendecomposition approach (which did not work). This basically involved finding $S = VDV^{T}$, setting all negative elements of $V,D = 1 \times 10^{-8}$, and reconstructing a new $S' = V' D' V'^{T}$ where $V',D'$ are matrices with only positive elements.
- I am aware of the Higham approach (which is implemented in R as
nearpd
), but it seems to only project to the nearest PSD matrix. I need a PD matrix for the Cholesky update.