View source: R/repair_metric.R
| repair_metric | R Documentation |
Returns a positive (semi)definite version of A together with a
diagnostic report of what was done. This is the explicit counterpart of
the constraints_remedy argument of genpca(): nothing in the package
repairs a metric silently, and this function lets you inspect the repair
before using the result.
repair_metric(
A,
method = c("ridge", "clip", "identity"),
rtol = .metric_rtol_default(),
name = "A",
diag_maxn = 2000L
)
A |
A square symmetric matrix (base matrix or |
method |
|
rtol |
Relative tolerance: eigenvalues above |
name |
Label used in messages. |
diag_maxn |
Largest dimension for which the report computes the full spectrum (minimum eigenvalue, rank, condition number); above it an iterative minimum eigenvalue estimate and a Gershgorin bound are reported, with rank and condition number unavailable. |
The repaired matrix (a Matrix), with attribute "repair_report"
of class "metric_repair_report": a list with name, method,
changed, n, min_eigenvalue_before, min_eigenvalue_after,
gershgorin_bound_before, shift (diagonal loading added by "ridge",
NA for "clip"), rank, condition_number and rtol.
genpca() (argument constraints_remedy)
A <- matrix(c(1, 2, 2, 1), 2) # eigenvalues 3 and -1
B <- repair_metric(A, method = "ridge")
attr(B, "repair_report")
C <- repair_metric(A, method = "clip")
eigen(as.matrix(C))$values
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.