Learn R Programming

clubSandwich (version 0.3.1)

impute_covariance_matrix: Impute a block-diagonal covariance matrix

Description

impute_covariance_matrix calculates a block-diagonal covariance matrix, given the marginal variances, the block structure, and an assumed correlation.

Usage

impute_covariance_matrix(vi, cluster, r,
  return_list = identical(as.factor(cluster), sort(as.factor(cluster))))

Arguments

vi

Vector of variances

cluster

Vector indicating which effects belong to the same cluster. Effects with the same value of `cluster` will be treated as correlated.

r

Vector or numeric value of assume correlation(s) between effect size estimates from each study.

return_list

Optional logical indicating whether to return a list of matrices (with one entry per block) or the full variance-covariance matrix.

Value

If cluster is appropriately sorted, then a list of matrices, with one entry per cluster, will be returned by default. If cluster is out of order, then the full variance-covariate matrix will be returned by default. The output structure can be controlled with the optional return_list argument.

Examples

Run this code
# NOT RUN {
library(metafor)
data(SATcoaching)
V_list <- impute_covariance_matrix(vi = SATcoaching$V, cluster = SATcoaching$study, r = 0.66)
MVFE <- rma.mv(d ~ 0 + test, V = V_list, data = SATcoaching)
coef_test(MVFE, vcov = "CR2", cluster = SATcoaching$study)

# }

Run the code above in your browser using DataLab