ltMatrices {mvtnorm} | R Documentation |
Multiple Lower Triangular or Symmetric Matrices
Description
A class representing multiple lower triangular or symmetric matrices and some methods.
Usage
ltMatrices(object, diag = FALSE, byrow = FALSE, names = TRUE)
syMatrices(object, diag = FALSE, byrow = FALSE, names = TRUE)
as.syMatrices(object)
## S3 method for class 'ltMatrices'
as.array(x, symmetric = FALSE, ...)
## S3 method for class 'syMatrices'
as.array(x, ...)
## S3 method for class 'ltMatrices'
diagonals(x, ...)
## S3 method for class 'syMatrices'
diagonals(x, ...)
## S3 method for class 'matrix'
diagonals(x, ...)
## S3 method for class 'integer'
diagonals(x, ...)
diagonals(x) <- value
## S3 replacement method for class 'ltMatrices'
diagonals(x) <- value
## S3 replacement method for class 'syMatrices'
diagonals(x) <- value
## S3 method for class 'ltMatrices'
solve(a, b, transpose = FALSE, ...)
## S3 method for class 'syMatrices'
chol(x, ...)
## S3 method for class 'ltMatrices'
aperm(a, perm, is_chol = FALSE, ...)
## S3 method for class 'ltMatrices'
Mult(x, y, transpose = FALSE, ...)
## S3 method for class 'syMatrices'
Mult(x, y, ...)
Tcrossprod(x, diag_only = FALSE)
Crossprod(x, diag_only = FALSE)
Lower_tri(x, diag = FALSE, byrow = attr(x, "byrow"))
chol2cov(x)
invchol2chol(x)
chol2invchol(x)
invchol2cov(x)
invchol2pre(x)
chol2pre(x)
Dchol(x, D = 1 / sqrt(Tcrossprod(x, diag_only = TRUE)))
invcholD(x, D = sqrt(Tcrossprod(solve(x), diag_only = TRUE)))
chol2cor(x)
invchol2cor(x)
chol2pc(x)
invchol2pc(x)
vectrick(C, S, A, transpose = c(TRUE, TRUE))
standardize(chol, invchol)
destandardize(chol = solve(invchol), invchol, score_schol)
Arguments
object |
a |
diag |
logical, |
byrow |
logical, |
names |
logical or character vector of length |
symmetric |
logical, object is interpreted as a symmetric matrix if
|
diag_only |
logical, compute diagonal elements of crossproduct only
if |
x , chol , invchol |
object of class |
value |
a matrix of diagonal elements to be assigned (of dimension |
a |
object of class |
perm |
a permutation of the covariance matrix corresponding to |
is_chol |
a logical indicating if |
D |
a matrix (of dimension |
y |
matrix with |
b |
matrix with |
C |
an object of class |
S |
an object of class |
A |
an object of class |
transpose |
a logical of length two indicating if |
score_schol |
score matrix for a standardized |
... |
additional arguments, currently ignored. |
Details
ltMatrices
interprets a matrix as lower triangular elements of
multiple lower triangular matrices. The corresponding class can be used to
store such matrices efficiently. Matrix multiplications, solutions to linear
systems, explicite inverses, and crossproducts can be computed based on such
objects. Details can be found in the lmvnorm_src
package vignette.
syMatrices
only store the lower triangular parts of multiple
symmetric matrices.
Value
The constructor ltMatrices
returns objects of class ltMatrices
with corresponding methods. The constructor syMatrices
returns objects of class
syMatrices
with a reduced set of methods.
See Also
vignette("lmvnorm_src", package = "mvtnorm")
Examples
J <- 4L
N <- 2L
dm <- paste0("d", 1:J)
xm <- paste0("x", 1:N)
(C <- ltMatrices(matrix(runif(N * J * (J + 1) / 2),
ncol = N, dimnames = list(NULL, xm)),
diag = TRUE, names = dm))
## dimensions and names
dim(C)
dimnames(C)
names(C)
## subset
C[,2:3]
## multiplication
y <- matrix(runif(N * J), nrow = J)
Mult(C, y)
## solve
solve(C)
solve(C, y)
## tcrossprod
Tcrossprod(C)
## convert to matrix
as.array(solve(C[1,]))[,,1]