[R-meta] simulating three-level meta-analysis
Filippo Gambarota
||||ppo@g@mb@rot@ @end|ng |rom gm@||@com
Thu Jun 16 10:10:52 CEST 2022
Thank you Wolfgang this is very helpful.
With that sentence about sampling variances, I meant that (if I
remember correctly) for tau estimation I have to use effect size weights
(thus sampling variances) so I was afraid that I need to sample values
according to some criteria (and not runif(...) as in my simulation) in
order to recover my parameters.
On Wed, 15 Jun 2022 at 19:36, Viechtbauer, Wolfgang (NP) <
wolfgang.viechtbauer using maastrichtuniversity.nl> wrote:
> Well, it doesn't want to go through, at least so far both of my replies
> are not showing up on the mailing list. No idea why. In case you reply,
> please still include the mailing list.
>
> Best,
> Wolfgang
>
> >-----Original Message-----
> >From: Viechtbauer, Wolfgang (NP)
> >Sent: Wednesday, 15 June, 2022 17:33
> >To: R meta
> >Cc: 'Filippo Gambarota'
> >Subject: RE: [R-meta] simulating three-level meta-analysis
> >
> >(I don't know why, but occasionally my posts to the mailing list do not go
> >through. This seems to be happening again, so let me try to resend this.)
> >
> >Hi Filippo,
> >
> >Not sure what you mean by "sampling variances that will be associated
> with a
> >certain value of tau2 (level 2) and tau3 (level 3)". But in any case,
> your code
> >isn't quite simulating data according to the three level model. This does:
> >
> >dat <- data.frame(paper = rep(1:ni, each=nj), study = 1:nj)
> >dat$b0_i <- rep(rnorm(ni, 0, taui), each=nj)
> >dat$b0_j <- rnorm(nrow(dat), 0, tauj)
> >dat$vi <- runif(nrow(dat), 0, 0.3)
> >dat$yi <- b0 + dat$b0_i + dat$b0_j + rnorm(nrow(dat), 0, sqrt(dat$vi))
> >
> >fit <- rma.mv(yi, vi, random = ~ study | paper, data = dat)
> >fit
> >
> >Best,
> >Wolfgang
> >
> >>-----Original Message-----
> >>From: R-sig-meta-analysis [mailto:
> r-sig-meta-analysis-bounces using r-project.org] On
> >>Behalf Of Filippo Gambarota
> >>Sent: Wednesday, 15 June, 2022 13:44
> >>To: R meta
> >>Subject: [R-meta] simulating three-level meta-analysis
> >>
> >>Hello!
> >>I'm trying to simulate a three-level meta-analysis model but I'm stuck
> >>on understanding how to generate sampling variances that will be
> >>associated with a certain value of tau2 (level 2) and tau3 (level 3).
> >>My approach so far is setting values for population parameters and
> >>generating sampling variances for the effect ij:
> >>
> >>```
> >>library(metafor)
> >>
> >>b0 <- 0.3 # effect
> >>ni <- 100 # number of papers
> >>nj <- 5 # number of effects within each paper
> >>
> >>taui <- 0.3 # level 3 tau
> >>tauj <- 0.1 # level 2 tau
> >>icc <- taui^2 / sum(taui^2 + tauj^2) # real ICC
> >>
> >># i-level data
> >>dati <- data.frame(paper = 1:ni,
> >> b0_i = rnorm(ni, 0, taui))
> >>
> >># j-level data
> >>datj <- data.frame(paper = rep(1:ni, nj),
> >> study = 1:sum(nj),
> >> b0_j = rnorm(sum(nj), 0, tauj))
> >>
> >>
> >>dat <- merge(dati, datj, by = "paper") # combine
> >>dat$vi <- runif(nrow(dat), 0, 0.3) # sampling variances at level 1
> >>dat$yi <- b0 + dat$b0_i + dat$b0_j + rnorm(nrow(dat), 0, dat$vi)
> >>
> >>fit <- rma.mv(yi, vi, random = ~study|paper, data = dat)
> >>```
> >>However, I'm sure that I'm doing wrong because taus are estimated
> >>using vi and the vis are not sampled with specific criteria.
> >>Does someone have some hints? Or in general suggestions about to setup
> >>a simulation like this?
> >>Thanks!
> >>
> >>--
> >>Filippo Gambarota
> >>PhD Student - University of Padova
> >>Department of Developmental and Social Psychology
> >>Website: filippogambarota
> >>Research Group: Colab Psicostat
>
--
*Filippo Gambarota*
PhD Student - University of Padova
Department of Developmental and Social Psychology
Website: filippogambarota <https://filippogambarota.netlify.app/>
Research Group: Colab <http://colab.psy.unipd.it/> Psicostat
<https://psicostat.dpss.psy.unipd.it/>
[[alternative HTML version deleted]]
More information about the R-sig-meta-analysis
mailing list