covMatrix: C++ implementation to compute the covariance matrix for a...

View source: R/locStra.r

covMatrixR Documentation

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.

Examples

require(locStra)
require(Matrix)
m <- matrix(sample(0:1,15,replace=TRUE),ncol=3)
sparseM <- Matrix(m,sparse=TRUE)
print(covMatrix(sparseM))


locStra documentation built on April 13, 2022, 1:07 a.m.

Related to covMatrix in locStra...