Calculates the sample covariance matrix, just as the function cov()
but returning a dspMatrixclass
object which efficiently
stores such a dense symmetric matrix.
1 
X 
data set from where to calculate the sample covariance matrix.
As the 
corrected 
flag set to 
This function makes the same calculation as the cov
function
but returns a sample covariance matrix stored in the spaceefficient class
dspMatrixclass
and, moreover, allows one for calculating
the uncorrected sum of squares and deviations which equals
(n1) * cov()
.
A sample covariance matrix stored as a dspMatrixclass
object.
See the Matrix
package for full details on this object class.
R. Castelo
qpPCC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26  require(graph)
require(mvtnorm)
nVar < 50 ## number of variables
nObs < 10 ## number of observations to simulate
set.seed(123)
g < randomEGraph(as.character(1:nVar), p=0.15)
Sigma < qpG2Sigma(g, rho=0.5)
X < rmvnorm(nObs, sigma=as.matrix(Sigma))
S < qpCov(X)
## estimate Pearson correlation coefficients by scaling the sample covariance matrix
R < cov2cor(as(S, "matrix"))
## get the corresponding boolean adjacency matrix
A < as(g, "matrix") == 1
## Pearson correlation coefficients of the present edges
summary(abs(R[upper.tri(R) & A]))
## Pearson correlation coefficients of the missing edges
summary(abs(R[upper.tri(R) & !A]))

Questions? Problems? Suggestions? Tweet to @rdrrHQ or email at ian@mutexlabs.com.
All documentation is copyright its authors; we didn't write any of that.