covMatrix: C++ implementation to compute the covariance matrix for a (sparse) input matrix. The function is equivalent to the R command 'cov' applied to matrices.
Description
C++ implementation to compute the covariance matrix for a (sparse) input matrix. The function is equivalent to the R command 'cov' applied to matrices.
Usage
covMatrix(m, useCpp = TRUE, sparse = TRUE)
Arguments
m
A (sparse) matrix for which the covariance matrix is sought. The input matrix is assumed to be oriented to contain the data for one individual per column.
useCpp
Flag to switch between R or C++ implementations. Default is useCpp=TRUE.
sparse
Flag to switch between purpose-built dense or sparse implementations. Default is sparse=TRUE.
Value
The covariance matrix of m.
References
R Core Team (2014). R: A Language and Environment for Statistical Computing. R Foundation for Stat Comp, Vienna, Austria.
# NOT RUN {require(locStra)
require(Matrix)
m <- matrix(sample(0:1,15,replace=TRUE),ncol=3)
sparseM <- Matrix(m,sparse=TRUE)
print(covMatrix(sparseM))
# }