Description Usage Arguments Value References See Also Examples
implements the alternating projection algorithm by Glunt et al. (1990) to calculate the nearest conditionally
negative semi-definite (CNSD) matrix (or: the nearest Euclidean distance matrix).
The function is similar to the
nearPD function from the
which implements a very similar algorithm for finding the nearest Positive Semi-Definite (PSD) matrix.
1 2 3 4 5 6 7
nearCNSD( x, eig.tol = 1e-08, conv.tol = 1e-08, maxit = 1000, conv.norm.type = "F" )
symmetric matrix, to be turned into a CNSD matrix.
eigenvalue torelance value. Eigenvalues between
convergence torelance value. The algorithm stops if the norm of the difference between two iterations is below this value.
maximum number of iterations. The algorithm stops if this value is exceeded, even if not converged.
type of norm, by default the F-norm (Frobenius). See
F-norm between original and resulting matrices
the number of performed
the relative value used for the tolerance convergence criterion
a boolean that records whether the algorithm
Glunt, W.; Hayden, T. L.; Hong, S. and Wells, J. An alternating projection algorithm for computing the nearest Euclidean distance matrix, SIAM Journal on Matrix Analysis and Applications, SIAM, 1990, 11, 589-600
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
# example using Insert distance with permutations: x <- list(c(2,1,4,3),c(2,4,3,1),c(4,2,1,3),c(4,3,2,1),c(1,4,3,2)) D <- distanceMatrix(x,distancePermutationInsert) print(D) is.CNSD(D) nearD <- nearCNSD(D) print(nearD) is.CNSD(nearD$mat) # or example matrix from Glunt et al. (1990): D <- matrix(c(0,1,1,1,0,9,1,9,0),3,3) print(D) is.CNSD(D) nearD <- nearCNSD(D) print(nearD) is.CNSD(nearD$mat) # note, that the resulting values given by Glunt et al. (1990) are 19/9 and 76/9
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.