sampleCovMat | R Documentation |
This function computes a sample covariance matrix.
sampleCovMat(sample)
sample |
a |
When y[1], ..., y[n] is a sequence of p-dimensional vectors y[i] the sample covariance matrix S is equal to
S = (1/(n-1)) sum[i=1][n] (y[i] - m)(y[i] - m)'
where
m = (1/n) sum[i=1][n] y[i].
When n=1 the function returns just sum of squares.
This function returns a matrix.
Arnošt Komárek arnost.komarek@mff.cuni.cz
## Sample some values z1 <- rnorm(100, 0, 1) ## first components of y z2 <- rnorm(100, 5, 2) ## second components of y z3 <- rnorm(100, 10, 0.5) ## third components of y ## Put them into a data.frame sample <- data.frame(z1, z2, z3) ## Compute a sample covariance matrix sampleCovMat(sample)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.