r1: Correlational Measures for Matrices

View source: R/rx.R

r1R Documentation

Correlational Measures for Matrices

Description

Matrix similarity as described by Ramsey et al. (1984).

Usage

r1(X1, X2, center = TRUE, impute = FALSE)

r2(
  X1,
  X2,
  center = TRUE,
  impute = FALSE,
  impute_par = list(max_iter = 20, tol = 10^-5)
)

r3(
  X1,
  X2,
  center = TRUE,
  impute = FALSE,
  impute_par = list(max_iter = 20, tol = 10^-5)
)

r4(
  X1,
  X2,
  center = TRUE,
  impute = FALSE,
  impute_par = list(max_iter = 20, tol = 10^-5)
)

GCD(
  X1,
  X2,
  ncomp1 = min(dim(X1)),
  ncomp2 = min(dim(X2)),
  center = TRUE,
  impute = FALSE,
  impute_par = list(max_iter = 20, tol = 10^-5)
)

Arguments

X1

first matrix to be compared (data.frames are also accepted).

X2

second matrix to be compared (data.frames are also accepted).

center

logical indicating if input matrices should be centered (default = TRUE).

impute

logical indicating if missing values are expected in X1 or X2.

impute_par

named list of imputation parameters in case of NAs in X1/X2.

ncomp1

(GCD) number of subspace components from the first matrix (default: full subspace).

ncomp2

(GCD) number of subspace components from the second matrix (default: full subspace).

Details

Details can be found in Ramsey's paper:

  • r1: inner product correlation

  • r2: orientation-independent inner product correlation

  • r3: spectra-independent inner product correlations (including orientation)

  • r4: Spectra-Independent inner product Correlations

  • GCD: Yanai's Generalized Coefficient of Determination (GCD) Measure. To reproduce the original GCD, use all components. When X1 and X2 are dummy variables, GCD is proportional with Pillai's criterion: tr(W^-1(B+W)).

Value

A single value measuring the similarity of two matrices.

Author(s)

Kristian Hovde Liland

References

Ramsay, JO; Berg, JT; Styan, GPH; 1984. "Matrix Correlation". Psychometrica 49(3): 403-423.

See Also

SMI, RV (RV2/RVadj), Rozeboom, Coxhead, allCorrelations (matrix correlation comparison), PCAcv (cross-validated PCA), PCAimpute (PCA based imputation).

Examples

X1  <- matrix(rnorm(100*300),100,300)
usv <- svd(X1)
X2  <- usv$u[,-3] %*% diag(usv$d[-3]) %*% t(usv$v[,-3])

r1(X1,X2)
r2(X1,X2)
r3(X1,X2)
r4(X1,X2)
GCD(X1,X2)
GCD(X1,X2, 5,5)

# Missing data
X1[c(1, 50, 400, 900)] <- NA
X2[c(10, 200, 450, 1200)] <- NA
r1(X1,X2, impute = TRUE)
r2(X1,X2, impute = TRUE)
r3(X1,X2, impute = TRUE)
r4(X1,X2, impute = TRUE)
GCD(X1,X2, impute = TRUE)
GCD(X1,X2, 5,5, impute = TRUE)



khliland/MatrixCorrelation documentation built on Feb. 5, 2023, 3:13 a.m.