nearest_pd: Compute the Nearest Positive-Definite Matrix.

View source: R/metrics.R

nearest_pdR Documentation

Compute the Nearest Positive-Definite Matrix.

Description

This function computes the nearest positive-definite matrix to some matrix A.

Usage

nearest_pd(X)

Arguments

X

Either a numeric vector or a square matrix. If a vector is provided, a matrix will be created of the form found in cyclic_matrix.

Details

This function computes the nearest positive-definite matrix to some matrix A.

The procedure to do so is as follows For a matrix X, compute the symmetric matrix B = (A + A^{T}) / 2. Let B = UH be the polar decomposition of B. The nearest positive-definite matrix to X is X_{F} = (B + H) / 2.

Unlike shrinking, only an autocorrelation matrix can be returned, not an autocovariance function.

The implementation is a translation of https://au.mathworks.com/matlabcentral/fileexchange/42885-nearestspd#functions_tab .

Value

The closest positive-definite autocorrelation matrix.

References

Higham, N. J. (1988). Computing a nearest symmetric positive semidefinite matrix. Linear Algebra and its Applications, 103, 103–118. https://doi.org/10.1016/0024-3795(88)90223-6

D'Errico, J. (2025). nearestSPD (https://www.mathwor ks.com/matlabcentral/fileexchange/42885-nearestspd), MATLAB Central File Exchange. Retrieved August 2, 2025.

Examples

X <- c(1, 0, -1.1)
nearest_pd(X)
check_pd(nearest_pd(X))

CovEsts documentation built on Sept. 10, 2025, 10:39 a.m.

Related to nearest_pd in CovEsts...