basiscor
computes the correlation matrix between
basis vectors, i.e. the columns of its basis
matrix -- which is the model's first matrix factor.
profcor
computes the correlation matrix between
basis profiles, i.e. the rows of the coefficient
matrix -- which is the model's second matrix factor.
basiscor(x, y, ...) profcor(x, y, ...)
basis
or coef
.basis
or coef
, and dimensions
compatible with x
. If missing the correlations are
computed between x
and y=x
.cor
.Each generic has methods defined for computing
correlations between NMF models and/or compatible
matrices. The computation is performed by the base
function cor
.
signature(x = "NMF", y =
"matrix")
: Computes the correlations between the basis
vectors of x
and the columns of y
.
signature(x = "matrix", y =
"NMF")
: Computes the correlations between the columns of
x
and the the basis vectors of y
.
signature(x = "NMF", y = "NMF")
:
Computes the correlations between the basis vectors of
x
and y
.
signature(x = "NMF", y =
"missing")
: Computes the correlations between the basis
vectors of x
.
signature(x = "NMF", y = "matrix")
:
Computes the correlations between the basis profiles of
x
and the rows of y
.
signature(x = "matrix", y = "NMF")
:
Computes the correlations between the rows of x
and the basis profiles of y
.
signature(x = "NMF", y = "NMF")
:
Computes the correlations between the basis profiles of
x
and y
.
signature(x = "NMF", y =
"missing")
: Computes the correlations between the basis
profiles of x
.
# generate two random NMF models
a <- rnmf(3, 100, 20)
b <- rnmf(3, 100, 20)
# Compute auto-correlations
basiscor(a)
## [,1] [,2] [,3]
## [1,] 1.00000 0.08277 -0.09167
## [2,] 0.08277 1.00000 -0.17981
## [3,] -0.09167 -0.17981 1.00000
profcor(a)
## [,1] [,2] [,3]
## [1,] 1.00000 0.05718 -0.0494
## [2,] 0.05718 1.00000 -0.3204
## [3,] -0.04940 -0.32039 1.0000
# Compute correlations with b
basiscor(a, b)
## [,1] [,2] [,3]
## [1,] 0.13191 0.06525 0.05398
## [2,] 0.06914 -0.07215 0.08395
## [3,] -0.11954 0.05423 -0.12475
profcor(a, b)
## [,1] [,2] [,3]
## [1,] 0.2968 0.3300 -0.2138
## [2,] 0.1406 -0.0947 -0.1564
## [3,] 0.2673 0.2512 -0.2651
# try to recover the underlying NMF model 'a' from noisy data
res <- nmf(fitted(a) + rmatrix(a), 3)
# Compute correlations with the true model
basiscor(a, res)
## [,1] [,2] [,3]
## [1,] -0.02656 0.94520 -0.04248
## [2,] 0.88282 0.06435 -0.30398
## [3,] 0.02106 -0.14757 0.95249
profcor(a, res)
## [,1] [,2] [,3]
## [1,] -0.02707 0.9365 -0.01096
## [2,] 0.97684 0.2234 -0.50404
## [3,] -0.29382 -0.2544 0.96962
# Compute correlations with a random compatible matrix
W <- rmatrix(basis(a))
basiscor(a, W)
## [,1] [,2] [,3]
## [1,] -0.082084 -0.004068 0.1733630
## [2,] -0.150145 0.040432 -0.1231361
## [3,] 0.007276 -0.138978 -0.0008321
identical(basiscor(a, W), basiscor(W, a))
## [1] FALSE
H <- rmatrix(coef(a))
profcor(a, H)
## [,1] [,2] [,3]
## [1,] 0.3823 -0.34576 0.3678
## [2,] 0.2335 0.07934 -0.2875
## [3,] -0.2209 -0.08092 0.2771
identical(profcor(a, H), profcor(H, a))
## [1] FALSE