corCosine: cosine correlation

View source: R/corCosine.R

corCosineR Documentation

cosine correlation

Description

Calculates the cosine correlation(s) between two vectors or conformable matrices.

Usage

corCosine(x, y)

Arguments

x

a numeric vector or matrix.

y

a vector or matrix with compatible dimensions to x.

Details

For two vectors, X and Y, the cosine similarity is defined as

similarity=cos(\theta)=(\sum XY) \div (\sqrt(\sum X^2)\times \sqrt(\sum Y^2))

. For centered data the cosine and Pearson's correlation coefficients are equivalent.

Value

a numeric matrix of cosine correlations.

Note

  • does not support missing values ('NA' nor 'NaN')

References

van Dongen S, Enright AJ. Metric distances derived from cosine similarity and Pearson and Spearman correlations. arXiv:1208.3145 [cs, stat] [Internet]. 2012 [cited 2016 Apr 22]; http://arxiv.org/abs/1208.3145

See Also

ntp


MolecularPathologyLab/MmCMS documentation built on Oct. 18, 2023, 10:42 p.m.