| vec2sigma | R Documentation |
Conversion between covariance matrices and their upper-triangular elements
vec2sigma(x, groups = NULL, visits = NULL, simplify = FALSE)
sigma2vec(x)
x |
(numeric) for |
groups |
(character) group names of the covariance matrices. If
|
visits |
(character) optional row and column names of the matrices. |
simplify |
(logical) if |
vec2sigma constructs symmetric (covariance) matrices from a vector of
upper-triangular elements (column-major, including the diagonal), e.g., the
covariance parameters returned by estimate(fit, sigma = TRUE) for an mmrm
model. The vector may contain the elements of several matrices of the same
dimension (one per group), stacked after each other. sigma2vec is the
inverse operation.
vec2sigma: list of matrices named by group (or a matrix if
simplify = TRUE and there is a single group). sigma2vec: numeric
vector with the upper-triangular elements of each matrix.
S <- matrix(c(2, 1, 1, 3), 2)
x <- sigma2vec(list(sigma = S))
x
vec2sigma(x)
vec2sigma(x, groups = "sigma", visits = c("v1", "v2"), simplify = TRUE)
## Two groups
vec2sigma(c(1, 0.5, 2, 3, 1, 4), groups = c("A", "B"))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.