[R-meta] Tau2 estimate problem
Viechtbauer, Wolfgang (SP)
wo||g@ng@v|echtb@uer @end|ng |rom m@@@tr|chtun|ver@|ty@n|
Thu Oct 10 14:38:18 CEST 2019
Hi Mutlu,
The problem is in this line:
y1=c(rnorm(study.nr, mean = eff.size, sd = t2+s2))
Note that 'sd' is for specifying the SD. So it should be:
y1=c(rnorm(study.nr, mean = eff.size, sd = sqrt(t2+s2)))
Then it will work as expected.
Best,
Wolfgang
-----Original Message-----
From: R-sig-meta-analysis [mailto:r-sig-meta-analysis-bounces using r-project.org] On Behalf Of Mutlu Umaroglu
Sent: Thursday, 10 October, 2019 14:29
To: r-sig-meta-analysis using r-project.org
Subject: [R-meta] Tau2 estimate problem
Dear All,
I generated random data for meta analysis with user-defined effect size
and tau2 (eg. es=1, T^2=0.3). After generating random data, I perform a
meta-analysis. However, the results (for tau2) are different from
user-defined tau2. I need some technical assistance to fix code.
Regards,
Mutlu
rowMeans(es2) #1
[1] 0.9941907 0.9941133
> rowMeans(tu2) #0.3
[1] 0.08509195 0.08346508
----
library(metafor)
library(Sim.PLFN)
set.seed(9999)
sml.nr=1000 #1000 simulation
study.nr=10 #with 10 studies in meta analysis
eff.size=1 #Effect size for meta analysis
t2=.3 #Tau2 for meta analysis
es2<-NULL
tu2<-NULL
for (i in 1:sml.nr){
s2=Trunc(n=study.nr, T.dist="chisq", T.dist.par=1, L=0.36, R=2.4)/4
y1=c(rnorm(study.nr, mean = eff.size, sd = t2+s2))
metadata<-data.frame(y1,s2)
DLmet<-rma(y1,s2,data=metadata,method="DL")
REMLmet<-rma(y1,s2,data=metadata,method="REML")
EffectSize= c(DLmet$b,REMLmet$b)
es2 = cbind(es2, EffectSize)
taau2= c(DLmet$tau2,REMLmet$tau2)
tu2 = cbind(tu2, taau2)
}
More information about the R-sig-meta-analysis
mailing list