[R-meta] Question about inverse variance weighting using the Metafor package

Viechtbauer, Wolfgang (SP) wolfg@ng@viechtb@uer @ending from m@@@trichtuniver@ity@nl
Mon Jul 30 17:23:29 CEST 2018


Dear Howard,

Please always keep the mailing list in CC when replying.

Yes, the default is to use inverse-variance weighting. For a FE model, the weights are 1/vi, where vi is the sampling variance of the ith study. For a RE model, the weights are 1/(vi + tau^2), where tau^2 is the between-study variance (amount of heterogeneity).

Best,
Wolfgang

-----Original Message-----
From: Howard Friedman [mailto:howard.friedman using columbia.edu] 
Sent: Monday, 30 July, 2018 13:40
To: Viechtbauer, Wolfgang (SP)
Subject: Re: [R-meta] Question about inverse variance weighting using the Metafor package

Wolfgang,

Thank you very much for your patience as I come up to speed.  In order to make sure I have my current code 100% correct now, I would greatly appreciate it if you can confirm for me that the default setting for the rma function is variance-weighting.
I have tested this with some dummy code and it appears to be the case but I want to be absolutely certain.

So, the code below computes the variance-weighted mean difference FE model

fig_1 <- escalc(n1i = n_controls, n2i = n_treatment, m1i = mean_controls, m2i = mean_ treatment,  sd1i = sd_controls, sd2i = sd_ treatment, data = input measure = "MD", append = TRUE) 

rma(yi, vi, method="FE", data=fig_1) 

And this below computes the variance-weighted random effects model:

rma(yi, vi, data=fig_1) 

Again, I greatly appreciate your guidance and help.

Sincerely,
Howard

On Mon, Jul 30, 2018 at 6:54 AM, Viechtbauer, Wolfgang (SP) <wolfgang.viechtbauer using maastrichtuniversity.nl> wrote:
Dear Howard,

1) Not sure what this step is supposed to do. It is not a pooled variance in the usual sense (https://en.wikipedia.org/wiki/Pooled_variance). Also, I am not sure where this value is coming back in the further steps.

2) This indeed computes the observed mean differences and corresponding sampling variances.

3) Is 'var_total' what you compute under step 1? Then I wouldn't do that. You should use weights that correspond to the inverse of the sampling variances, not the sum of the two sample variances (note: sample variance != sampling variance of the mean difference -- the sampling variance involves the sample sizes). So, just use:

rma(yi, vi, method="FE", data=fig_1)

4) Same thing, plus plus you are fitting a random-effects model here. Unless you have very good reasons for deviating from the default weights, just use:

rma(yi, vi, data=fig_1)

(method="REML" is the default).

As for some discussion of the use of custom weights, see here:

https://stat.ethz.ch/pipermail/r-sig-meta-analysis/2018-July/000909.html

But using 1/(sd_controls^2+sd_treatment^2) as weights makes little sense in any case.

Best,
Wolfgang

-----Original Message-----
From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces using r-project.org] On Behalf Of Howard Friedman
Sent: Sunday, 29 July, 2018 21:25
To: r-sig-meta-analysis using r-project.org
Subject: [R-meta] Question about inverse variance weighting using the Metafor package

I am using the Metafor package for the first time.  I read the
documentation and wanted to confirm that I am doing the correct steps to
computing the weighted mean difference where the weights are inverse
variance.

My data set has inputs for each study of n_control, n_treatment,
mean_controls, mean_treatment, sd_controls, and sd_treatment.  Am I correct
that to do the inverse weighting I need to do the following:

(1)    Compute the pooled variance by defining variance= sd_controls^2+
sd_treatment^2

(2)    Define my variables as below:

fig_1 <- escalc(n1i = n_controls, n2i = n_treatment, m1i = mean_controls,
m2i = mean_ treatment,  sd1i = sd_controls, sd2i = sd_ treatment, data =
fig_1, measure = "MD", append = TRUE)

(3)    Then for my fixed effects model weighting by 1/variance, run

rma(yi, vi, method="FE",weights=1/var_total,data=fig_1)

(4)    And for my variable effects model weighted by 1/variance, run

rma(yi, vi, weights=1/var_total,data=fig_1)

Appreciate you feedback or corrections on this approach.

Thank you,

Howard

-- 

Columbia University School of International and Public Affairs; School of
Public Health
www.linkedin.com/in/howard-friedman-590ba8
www.Howard-Friedman.com


More information about the R-sig-meta-analysis mailing list