Compute Second-Order Similarity Scores
second_order_similarity.Rd
Calculates correlation-based second order similarity between:
A full NxN distance matrix computed from
X
viadistfun
, andA
Dref
matrix (the "reference" dissimilarities).
For each row i
, this excludes same-block comparisons by selecting which(block_var != block_var[i])
.
Usage
second_order_similarity(
distfun,
X,
Dref,
block_var,
method = c("pearson", "spearman")
)
Arguments
- distfun
An S3 distance object (see
create_dist
) specifying how to compute a pairwise distance matrix fromX
.- X
A numeric matrix (rows = observations, columns = features).
- Dref
A numeric NxN reference matrix of dissimilarities (e.g., from an ROI mask or a prior).
- block_var
A vector indicating block/group memberships for each row in
X
.- method
Correlation method: "pearson" or "spearman".
Value
A numeric vector of length nrow(X)
, where each entry is
the correlation (using method
) between distance_matrix[i, valid]
and
Dref[i, valid]
, with valid = which(block_var != block_var[i])
.