Skip to content
Prev 3893 / 5636 Next

[R-meta] Vairance-Covariance Matrix with Shared Control Group

Hi Arthur,

1) Yes, when you specify w1 and w2, then these will be used to compute a more accurate value of the correlation that is induced by the shared control group/condition.

2) Yes, using the size of the two groups/conditions is pretty good. The most accurate thing to do is to use the weights corresponding to the arm-based outcomes. Let me illustrate this.

############################################################

# say you have these data; this is the same data as used here: 
# https://www.metafor-project.org/doku.php/analyses:gleser2009#dichotomous_response_variable

dat <- data.frame(study=c(1,1,2,3,3,3), trt=c(1,2,1,1,2,3), ctrl=0,
                  ai=c( 40, 40, 10,150,150,150), n1i=c(1000,1000,200,2000,2000,2000),
                  ci=c(100,150, 15, 40, 80, 50), n2i=c(4000,4000,400,1000,1000,1000))
dat$pti <- with(dat, ci / n2i)
dat$pci <- with(dat, ai / n1i)

dat <- escalc(measure="RR", ai=ai, ci=ci, n1i=n1i, n2i=n2i, data=dat)
dat

# note: ai and n1i are the data for the control group, ci and n2i for the treatment groups

# as discussed by Gleser & Olkin (2009), we can construct the var-cov matrix of the log
# risk ratios as follows

calc.v <- function(x) {
   v <- matrix((1-x$pci[1])/(x$n1i[1]*x$pci[1]), nrow=nrow(x), ncol=nrow(x))
   diag(v) <- x$vi
   v
}
 
V <- bldiag(lapply(split(dat, dat$study), calc.v))
cov2cor(V) # examing the correlation matrix

# now let's use vcalc() for this

V <- vcalc(vi, cluster=study, grp1=ctrl, grp2=trt, data=dat)
cov2cor(V)

# not quite right since we get 0.5 for the correlations

# now let's use the group sizes as weights

V <- vcalc(vi, cluster=study, grp1=ctrl, grp2=trt, w1=n1i, w2=n2i, data=dat)
cov2cor(V)

# closer (and good enough I would say)

# compute the log proportions for the control and treatment groups

dat <- escalc(measure="PLN", xi=ai, ni=n1i, data=dat, var.names=c("yc","vc"))
dat <- escalc(measure="PLN", xi=ci, ni=n2i, data=dat, var.names=c("yt","vt"))
dat

# use the weights (inverse sampling variances) of these arm-based outcomes

V <- vcalc(vi, cluster=study, grp1=ctrl, grp2=trt, w1=1/vc, w2=1/vt, data=dat)
cov2cor(V)

# exactly the same as what we with calc.v() above

############################################################

Using the group sizes is probably good enough in most cases, I would say.

As for 'rho' - this has nothing to do with the shared groups. The rho in that last example (dat.knapp2017) is specified for studies where the same groups were examined under varying conditions.

I hope this answers your questions.

Best,
Wolfgang