vech | R Documentation |
Stacks elements of the lower triangle of a numeric symmetric matrix A.
vech(A, use.Names = TRUE, tol = .Machine$double.eps^0.5)
A |
A matrix with m rows and n columns. |
use.Names |
Logical. If TRUE, the names of A are taken to be names of the stacked matrix. Default: TRUE. |
tol |
A numeric tolerance level used to check if a matrix is symmetric. That is, a matrix is symmetric if the difference between the matrix and its transpose is between - |
For a symmetric matrix A, the vectorization of A contains more information than necessary. The half-vectorization, denoted vech()
, of a symmetric square n by n matrix A is the vectorization of the lower triangular portion.
A vector with n(n+1)/2 elements.
Unlike other vech()
functions available on CRAN, matrixNormal version may inherit names from matrices to their vectorized forms.
x <- matrix(c(1, 2, 2, 4), nrow = 2, byrow = TRUE, dimnames = list(1:2, c("Sex", "Smoker")) ) print(x) # Example 1 vech(x) # If you just want the vectorized form vech(x, use.Names = FALSE) # Example 2: If one has NA's x[1, 2] <- x[2, 1] <- NA vech(x)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.