mCorrCov | R Documentation |
Given a correlation matrix and vector of standard deviations (or vector of means and vector of variation coefficients) returns a covariance matrix.
mCorrCov(mcorr, sigma = 1, mu = NULL, coefvar = NULL)
mcorr |
a (non-empty) numeric correlation matrix. |
sigma |
an optional vector of standard deviations. |
mu |
an optional vector of means. |
coefvar |
an optional vector of coefficients of variation. |
coefvar
= sigma
/mu
.
If sigma
, mu
or coefvar
are not specified, it´s assumed that default values for standard error's are 1. Length of standard error's is created using number of rows of correlation matrix.
It's necessary to provide sigma
or mu
and coefvar
(both) in order to obtain a desired covariance matrix.
Length of vectors is taken using rep
. Pay attention if vectors don't have same length!
mCorrCov
gives the covariance matrix for a specified correlation matrix.
A <- matrix(c(1,2,2,1), nrow = 2, byrow = TRUE) mCorrCov(A) B <- matrix(c(1,0.8,0.7,0.8,1,0.55,0.7,0.55,1), nrow = 3, byrow = TRUE) mCorrCov(B,mu = c(2,3.5,1), coefvar = c(0.3,0.5,0.7))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.