View source: R/regime-integration.R
| regime_correlation_pca | R Documentation |
Convert each regime covariance matrix to a correlation matrix, vectorize the
upper-triangle off-diagonal entries, and run stats::prcomp() on the
resulting regime-by-correlation matrix. When use_correlation = TRUE, the
function warns if all retained covariance matrices are scalar-proportional to
one another. That pattern is expected for proportional search$VCVs from the
scalar bifrost search model and should not be interpreted as independent
post-hoc covariance reconfiguration evidence.
regime_correlation_pca(
x,
use_correlation = TRUE,
center = TRUE,
scale. = TRUE,
tip_counts = NULL,
regime_ages = NULL,
trait_labels = NULL,
min_tips = NULL,
...
)
x |
A |
use_correlation |
Logical; if |
center, scale. |
Passed to |
tip_counts |
Optional named numeric vector of tip counts. |
regime_ages |
Optional named numeric vector of regime ages. |
trait_labels |
Optional labels for the matrix rows/columns. Supply a named vector to map internal trait names to display labels, or an unnamed vector in matrix order. Resolved labels must be unique and not blank. |
min_tips |
Optional positive whole-number minimum tip count for
inclusion when |
... |
Reserved for future extensions. |
An object of class regime_correlation_pca containing the prcomp
object, vectorized input matrix, scores, loadings, variance explained,
regime IDs, trait labels, optional diagnostics, and a settings list that
records the PCA scaling, tip-count filter, and whether retained covariance
matrices were scalar-proportional.
make_correlation <- function(r12, r13, r23) {
matrix(
c(1, r12, r13, r12, 1, r23, r13, r23, 1),
nrow = 3,
dimnames = list(c("bill", "wing", "tail"),
c("bill", "wing", "tail"))
)
}
covariances <- list(
r1 = make_correlation(0.1, 0.2, 0.3),
r2 = make_correlation(0.2, 0.1, 0.4),
r3 = make_correlation(-0.1, 0.3, 0.2),
r4 = make_correlation(0.4, -0.2, 0.1)
)
pca <- regime_correlation_pca(covariances)
pca$variance_explained
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.