mix.vcov: Computing Variance-Covariance Matrices for Effect Sizes of...

View source: R/mix.vcov.R

mix.vcovR Documentation

Computing Variance-Covariance Matrices for Effect Sizes of the Same or Different Types

Description

The function r.vcov computes effect sizes and variance-covariance matrices between effect sizes of the same of different types. Effect sizes include mean difference (MD), standardized mean difference (SMD), log odds ratio (logOR), log risk ratio (logRR), and risk difference (RD). Formulas are in Table I of Wei et al.'s paper (2013).

Usage

mix.vcov(d, r, nt, nc,
         st, sc, n_rt = NA, n_rc = NA,
         sdt, sdc, type,
         name = NULL, na.impute = NA)

Arguments

d

A N \times p matrix or data frame with mean differences (MD) and/or standard mean differences (SMD) from the N studies. d[i,j] is the value from study i for outcome j. If outcome j is not MD or SMD, NA has to be imputed in column j.

r

A N-dimensional list of p \times p correlation matrices for the p outcomes from the N studies. r[[k]][i,j] is the correlation coefficient between outcome i and outcome j from study k.

nt

A N \times p matrix storing sample sizes in the treatment group reporting the p outcomes. nt[i,j] is the sample size from study i reporting outcome j.

nc

A matrix defined in a similar way as nt for the control group.

st

A N \times p matrix recording number of participants with event for all outcomes (dichotomous) in treatment group. st[i,j] reports number of participants with event for outcome j in treatment group for study i. If outcome j is not dichotomous, NA has to be imputed in column j.

sc

Defined in a similar way as st for the control group.

n_rt

A N-dimensional list of p \times p matrices storing sample sizes in the treatment group reporting pairwise outcomes in the off-diagonal elements. n_rt[[k]][i,j] is the sample size reporting both outcome i and outcome j from study k. Diagonal elements of these matrices are discarded. The default value is NA, which means that the smaller sample size reporting the corresponding two outcomes is imputed: i.e. n_rt[[k]][i,j]=min(nt[k,i],nt[k,j]).

n_rc

A list defined in a similar way as n_rt for the control group.

sdt

A N \times p matrix storing sample standard deviations for each outcome from treatment group. sdt[i,j] is the sample standard deviation from study i for outcome j. If outcome j is not continuous such as MD or SMD, NA has to be imputed in the jth column.

sdc

A matrix defined in a similar way as sdt for the control group.

type

A p-dimensional vector indicating types of effect sizes. "MD" stands for mean difference, "SMD" stands for standardized mean difference, "logOR" stands for log odds ratio, "logRR" stands for log risk ratio, and "RD" stands for risk difference.

name

A p-dimensional vector storing names for the effect sizes.

na.impute

Missing values in d can be imputed by a numeric value, such as zero by setting na.impute = 0. With the default setting na.impute = NA, missing values are not imputed. If specifying na.impute = "average", missing values are imputed by the mean of d that is sample-size weighted from the complete records.

Value

ef

A N \times p data frame whose columns are computed effect sizes according to the input argument "type". SMD will be converted to Hedges's g (Wei and Higgins, 2013).

list.vcov

A N-dimensional list of p(p+1)/2 \times p(p+1)/2 matrices of computed variance-covariance matrices.

matrix.vcov

A N \times p(p+1)/2 matrix whose rows are computed variance-covariance vectors.

Author(s)

Min Lu

References

Lu, M. (2023). Computing within-study covariances, data visualization, and missing data solutions for multivariate meta-analysis with metavcov. Frontiers in Psychology, 14:1185012.

Wei, Y., & Higgins, J. (2013). Estimating within study covariances in multivariate meta-analysis with multiple outcomes. Statistics in Medicine, 32(7), 119-1205.

Examples

#########################################################################
# Example: Geeganage2010 data
# Preparing covariances for a multivariate meta-analysis
# Choose variable SBP, DBP, DD, D with effect sizes "MD","MD","RD","lgOR"
#########################################################################
data(Geeganage2010)
## set the correlation coefficients list r
r12 <- 0.71
r13 <- 0.5
r14 <- 0.25
r23 <- 0.6
r24 <- 0.16
r34 <- 0.16
r <- vecTosm(c(r12, r13, r14, r23, r24, r34))
diag(r) <- 1
mix.r <- lapply(1:nrow(Geeganage2010), function(i){r})
attach(Geeganage2010)
## compute variance co-variances
computvcov <- mix.vcov(type = c("MD", "MD", "RD", "lgOR"),
                       d = cbind(MD_SBP, MD_DBP, NA, NA),
                       sdt = cbind(sdt_SBP, sdt_DBP, NA, NA),
                       sdc = cbind(sdc_SBP, sdc_DBP, NA, NA),
                       nt = cbind(nt_SBP, nt_DBP, nt_DD, nt_D),
                       nc = cbind(nc_SBP, nc_DBP, nc_DD, nc_D),
                       st = cbind(NA, NA, st_DD, st_D),
                       sc = cbind(NA, NA, sc_DD, sc_D),
                       r = mix.r,
                       name = c("MD.SBP", "MD.DBP", "RD.DD", "lgOR.D"))
# save different effect sizes in y
y <- computvcov$ef
head(y)
# save variances and covariances of all the effect sizes in a matrix S
S <- computvcov$matrix.vcov
S[1, ]
## fixed-effect model
MMA_FE <- summary(metafixed(y = y, Slist = computvcov$list.vcov))
#######################################################################
# Running random-effects model using package "mixmeta" or "metaSEM"
#######################################################################
# Restricted maximum likelihood (REML) estimator from the mixmeta package
# library(mixmeta)
# mvmeta_RE <- summary(mixmeta(cbind(MD.SBP, MD.DBP, RD.DD, lgOR.D) ~ 1,
#                            S = S, data = y, method = "reml"))
# mvmeta_RE

# maximum likelihood estimators from the metaSEM package
# library(metaSEM)
# metaSEM_RE <- summary(meta(y = y, v = S))
# metaSEM_RE
##############################################################
# Plotting the result:
##############################################################
obj <- MMA_FE
# obj <- mvmeta_RE
# obj <- metaSEM_RE
# pdf("CI.pdf", width = 4, height = 7)
plotCI(y = computvcov$ef, v = computvcov$list.vcov,
        name.y = NULL, name.study = Geeganage2010$studyID,
        y.all = obj$coefficients[,1],
        y.all.se = obj$coefficients[,2],
        hline = c(0, 0, 0, 1))
# dev.off()

metavcov documentation built on July 9, 2023, 7:11 p.m.