Description Usage Arguments Value Author(s) References Examples
Calcultion of matrices of various similarity/distances, which takes use
of matrix multiplication. Note: the comparisons are made between
columns, similar to the cor
function, and unlike the
dist
function which compares between rows.
See the timing vignette for comparison of the performance of functions against standard dense calculations.
1 2 3 | sparseCov(X, Y = NULL, XtX = NULL)
sparseCosine(X, Y = NULL, XtX = NULL)
sparseEuclid(X, Y = NULL, XtX = NULL)
|
X |
a matrix X |
Y |
optional: a matrix Y, in which case columns of X will be compared to columns of Y. The resulting matrix will be ncol(X) by ncol(Y). |
XtX |
optional: if not using Y, supplying XtX, the crossproduct of X with itself, will be used rather than recalculating this in the function. |
A list with the covariance and correlation matrix of X, or X and Y; The cosine similarity matrix of X, or X and Y; The Euclidean distances matrix of X, or X and Y.
Michael Love
The sparseCov function was developed from a discussion here: http://stackoverflow.com/questions/5888287/running-cor-or-any-variant-over-a-sparse-matrix-in-r
1 2 3 4 5 6 | sds1 <- simulateSparseDataSet(100, c(5,5))
sds2 <- simulateSparseDataSet(100, c(2,2))
res <- sparseCov(sparseData(sds1))
res$cor
resxy <- sparseCov(sparseData(sds1),sparseData(sds2))
resxy$cor
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.