impute_covariance_matrix {clubSandwich} | R Documentation |
impute_covariance_matrix
calculates a block-diagonal covariance
matrix, given the marginal variances, the block structure, and an assumed
correlation.
impute_covariance_matrix(vi, cluster, r, return_list = identical(as.factor(cluster), sort(as.factor(cluster))))
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. |
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.
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)