as_bmat: Coerce R objects to block or diagonal matrices
Description
These are simple functions that may be helpful to create the matrix objects
that mrgsolve expects. Functions are named based on whether they create a
diagonal matrix (d), a block matrix (b), or a a correlation
matrix (c).
Usage
as_bmat(x, ...)
# S4 method for list
as_bmat(x, ...)
# S4 method for numeric
as_bmat(x, pat = "*", ...)
# S4 method for data.frame
as_bmat(x, pat = "*", cols = NULL, ...)
# S4 method for ANY
as_bmat(x, ...)
as_dmat(x, ...)
# S4 method for list
as_dmat(x, ...)
# S4 method for ANY
as_dmat(x, ...)
# S4 method for numeric
as_dmat(x, pat = "*", ...)
# S4 method for data.frame
as_dmat(x, pat = "*", cols = NULL, ...)
A numeric matrix for list and numeric methods. For data.frames,
a list of matrices are returned.
Details
Use as_dmat to create a diagonal matrix, as_bmat
to create a block matrix, and as_cmat to create a block
matrix where off-diagonal elements are understood to be correlations
rather than covariances. as_cmat uses as_bmat to
form the matrix and then converts off-diagonal elements to
covariances before returning.
The methods for data.frame will work down the rows
of the data frame and make the appropriate matrix from
the data in each row. The result is a list of matrices.