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

metabind() producing double() instead of integer() for N of studies in forest() #13

Closed fmmattioni closed 5 years ago

fmmattioni commented 5 years ago

I have noticed that when using metabind() it always gives me a double() instead of an integer() in the column showing the number of studies. I have tried to transform it in the metabind object, but it still doesn't change anything. I wonder if this is an issue in forest()?

reprex:

library(meta)
#> Loading 'meta' package (version 4.9-7).
#> Type 'help(meta)' for a brief overview.

data(Fleiss93cont)
# Add some (fictitious) grouping variables:
#
Fleiss93cont$age <- c(55, 65, 55, 65, 55)
Fleiss93cont$region <- c("Europe", "Europe", "Asia", "Asia", "Europe")
m1 <- metacont(n.e, mean.e, sd.e, n.c, mean.c, sd.c,
               data = Fleiss93cont, sm = "MD")

# Conduct two subgroup analyses
#
mu1 <- update(m1, byvar = age, bylab = "Age group")
mu2 <- update(m1, byvar = region, bylab = "Region")
# Combine subgroup meta-analyses and show forest plot with subgroup
# results
#
mb1 <- metabind(mu1, mu2)
#> Warning in metabind(mu1, mu2): Note, results from random effects model
#> extracted. Use argument pooled = "fixed" for results of fixed effect model.
mb1
#>             MD             95%-CI meta-analysis
#> 55     -1.0519 [-2.0636; -0.0403]     Age group
#> 65     -0.5152 [-1.8868;  0.8565]     Age group
#> Europe -1.0938 [-1.7704; -0.4173]        Region
#> Asia   -0.4591 [-2.6758;  1.7577]        Region
#> 
#> Number of studies combined: k = 5
#> 
#>                           MD             95%-CI     z p-value
#> Random effects model -0.7373 [-1.4577; -0.0170] -2.01  0.0448
#> 
#> Quantifying heterogeneity:
#> tau^2 = 0.1894; H = 1.19 [1.00; 1.91]; I^2 = 29.3% [0.0%; 72.6%]
#> 
#> Test of heterogeneity:
#>     Q d.f. p-value
#>  5.66    4  0.2260
#> 
#> Results for meta-analyses (random effects model):
#>             k      MD             95%-CI    Q  tau^2   I^2
#> Age group   5 -0.7373 [-1.4577; -0.0170] 5.66 0.1894 29.3%
#> Region      5 -0.7373 [-1.4577; -0.0170] 5.66 0.1894 29.3%
#> 
#> Details on meta-analytical method:
#> - Inverse variance method
#> - DerSimonian-Laird estimator for tau^2
forest(mb1)

Created on 2019-10-01 by the reprex package (v0.3.0)

guido-s commented 5 years ago

Again, thank you for reporting this issue which is not related to storing the sample sizes as double or integer. R function forest.meta() which is called internally in forest.metabind() treats the sample sizes as an additional numeric variable and rounds this variable according to argument 'digits.addcols' (which is 2 by default).

I solved this in forest.metabind() by storing the sample sizes as a character variable: x$data$k <- as.character(x$data$k) (see https://github.com/guido-s/meta/commit/c6a9bf6cf873cba1c77983f0d036cfdc99a6c046).

fmmattioni commented 5 years ago

Dear Prof. Schwarzer, thank you so much for looking into this in such a short time! That's perfect!