blsplit | R Documentation |
Function to split a block diagonal matrix into a list of sub-matrices.
blsplit(x, cluster, fun, args, sort=FALSE)
x |
a block diagonal matrix. |
cluster |
vector to specify the clustering variable to use for splitting. |
fun |
optional argument to specify a function to apply to each sub-matrix. |
args |
optional argument to specify any additional argument(s) for the function specified via |
sort |
logical to indicate whether to sort the list by the unique cluster values (the default is |
A list of one or more sub-matrices.
Wolfgang Viechtbauer wvb@metafor-project.org https://www.metafor-project.org
bldiag
for a function to create a block diagonal matrix based on sub-matrices.
vcalc
for a function to construct a variance-covariance matrix of dependent effect sizes or outcomes, which often has a block diagonal structure.
### copy data into 'dat'
dat <- dat.assink2016
### assume that the effect sizes within studies are correlated with rho=0.6
V <- vcalc(vi, cluster=study, obs=esid, data=dat, rho=0.6)
### split V matrix into list of sub-matrices
Vs <- blsplit(V, cluster=dat$study)
Vs[1:2]
lapply(Vs[1:2], cov2cor)
### illustrate the use of the fun and args arguments
blsplit(V, cluster=dat$study, cov2cor)[1:2]
blsplit(V, cluster=dat$study, round, 3)[1:2]
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.