Skip to content

(Slight) calculation discrepancy in escalc (metafor package)

2 messages · Stephen Ban, Viechtbauer Wolfgang (STAT)

#
The pooled standard deviation is calculated exactly how you describe it. There are, however, two differences between your approach and the way escalc() computes the SMD and corresponding sampling variance:

1) Instead of the equation for approximating the correction factor (J), escalc() uses the exact equation, namely:

gamma(mi/2)/(sqrt(mi/2)*gamma((mi-1)/2))

where mi = n1+n2-2. In your example, that is:
[1] 0.9027033

which is really only slightly different from the value you computed (0.903226) and hence, the corrected SMD value computed by escalc() and your computations essentially agree.

2) More importantly, the sampling variance (Vd) is computed in escalc() by plugging the *corrected* version of the SMD into the equation you gave and no further adjustment is made to Vd. This explains the more substantial difference you found between your computations of the sampling variance and the value returned by escalc(). This kind of difference will only be noticeable when the sample sizes are small (as in your example). 

One could debate which approach is "more" correct. Probably neither is appropriate here. The equation for the sampling variance given below is actually a large-sample approximation. For n1=n2=5, it's probably not accurate at all. An alternative would be to discard that equation altogether and instead use an unbiased estimate of the sampling variance, which can be obtained with:

escalc(measure="SMD", m1i=5,m2i=10,n1i=5,n2i=5,sd1i=1,sd2i=2,vtype="UB")

which gives a value of 1.0487, much bigger than either of the two values.

Best,

Wolfgang

--
Wolfgang Viechtbauer, Ph.D., Statistician
Department of Psychiatry and Psychology
School for Mental Health and Neuroscience
Faculty of Health, Medicine, and Life Sciences
Maastricht University, P.O. Box 616 (VIJV1)
6200 MD Maastricht, The Netherlands
+31 (43) 388-4170 | http://www.wvbauer.com