guido-s / meta

Official Git repository of R package meta
http://cran.r-project.org/web/packages/meta/index.html
GNU General Public License v2.0
82 stars 32 forks source link

Error when using both `id` and `byvar` together (i.e. three-level meta-analysis with subgroups) #38

Closed igelstorm closed 3 years ago

igelstorm commented 3 years ago

Hi,

I get the following error when calling metagen and passing in both an id (for three-level meta-analysis) and byvar (for subgroup analysis):

Error in add.w[j, ] <- c(meta1$sign.lower.tau, meta1$sign.upper.tau) : 
  number of items to replace is not a multiple of replacement length

Any idea what might cause this, and whether it's likely a bug or a problem with how we are trying to use the function?

Here's a minimal reproducible example (the error message is the same as we get with different data and some other differing arguments):

data(Pagliaro1992)

# Add fictitious grouping variables
Pagliaro1992$region <- rep(c("Europe", "Europe", "Asia", "Asia"), times = 7)
Pagliaro1992$id <- rep(c(1, 2, 3, 4), times = 7)

m <- metagen(logOR, selogOR,
             byvar = region,
             id = id,
             data = Pagliaro1992,
             sm = "OR")

Many thanks, Erik

guido-s commented 3 years ago

Erik,

Thank you for pointing out this bug. Albeit subgroup analysis was possible for a three-level model it was not fully operational. Should work now.

Best, Guido