Trouble with meta-analysis

brms version : 2.7.0, installed from github

Hello!

I have trouble reproducing a meta-analysis exemple with brms! Here is a reproducible exemple

# Import libraries
library(metafor)
library(brms)
library(tidyverse)

# Formate data
dat <- escalc(measure="ZCOR", ri=ri, ni=ni, data=dat.molloy2014,
              slab=paste(authors, year, sep="_"))
dat$sei <- sqrt(dat$vi)/sqrt(dat$ni)
dat$study <- paste(paste(dat$authors, dat$year, sep="_"))

## Formula
brm_form <- brmsformula(yi | se(sei) ~ 1 + (1|study))

## Prior
brm_prior <- prior(normal(0,1), class = "sd")

## Sample from the posterior
brm_out <- brm(formula = brm_form, prior = brm_prior, data = dat,
               iter = 500, warmup = 500, cores = 4)

The result I get is

 Erreur : is.atomic(x) is not TRUE 
13.stop(msg, call. = FALSE, domain = NA) 
12.stopifnot(is.atomic(x)) 
11.FUN(newX[, i], ...) 
10.apply(E, 2, var) 
9.throw_sampler_warnings(nfits) 
8..local(object, ...) 
7..fun(object = .x1, data = .x2, pars = .x3, include = .x4, iter = .x5, 
    seed = .x6, init = .x7, warmup = .x8, thin = .x9, control = .x10, 
    show_messages = .x11, chains = .x12, cores = .x13) 
6..fun(object = .x1, data = .x2, pars = .x3, include = .x4, iter = .x5, 
    seed = .x6, init = .x7, warmup = .x8, thin = .x9, control = .x10, 
    show_messages = .x11, chains = .x12, cores = .x13) at <text>#1
5.eval(expr, envir, ...) 
4.eval(expr, envir, ...) 
3.eval2(call, envir = args, enclos = parent.frame()) 
2.run(rstan::sampling, args) 
1.brm(formula = brm_form, prior = brm_prior, data = dat, iter = 500, 
    warmup = 500, cores = 4) 

Thank you for your help!
Lucas

This is strange. It seems to happen somewhere in rstan::sampling after the actual model fitting. Not sure what happens there… @bgoodri Can you perhaps take a look at this?

There are no post-warmup draws from the posterior distribution. It works if the iter = 500, warmup = 500 is eliminated.

2 Likes

It is often hard to discover our own trivial mistake… Thank you!