as_bmat | R Documentation |
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
).
as_bmat(x, ...)
## S4 method for signature 'list'
as_bmat(x, ...)
## S4 method for signature 'numeric'
as_bmat(x, pat = "*", ...)
## S4 method for signature 'data.frame'
as_bmat(x, pat = "*", cols = NULL, ...)
## S4 method for signature 'ANY'
as_bmat(x, ...)
as_dmat(x, ...)
## S4 method for signature 'list'
as_dmat(x, ...)
## S4 method for signature 'ANY'
as_dmat(x, ...)
## S4 method for signature 'numeric'
as_dmat(x, pat = "*", ...)
## S4 method for signature 'data.frame'
as_dmat(x, pat = "*", cols = NULL, ...)
as_cmat(x, ...)
x |
data frame or list. |
... |
arguments passed to |
pat |
regular expression, character. |
cols |
column names to use instead of |
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.
A numeric matrix for list and numeric methods. For data.frames, a list of matrices are returned.
bmat()
, dmat()
, cmat()
df <- data.frame(
OMEGA1.1 = c(1,2),
OMEGA2.1 = c(11,22),
OMEGA2.2 = c(3,4),
SIGMA1.1 = 1,
FOO=-1
)
as_bmat(df, "OMEGA")
as_dmat(df,"SIGMA")
as_dmat(df[1,],"OMEGA")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.