getsamples {metainc}R Documentation

Generate or extract samples of effect sizes from primary studies

Description

Obtains a matrix containing sampled effect sizes from primary studies of a meta-analysis.

Usage

getsamples(
  obj,
  param = NULL,
  package = NULL,
  n.samples = 10000,
  sm,
  transf = TRUE
)

Arguments

obj

Meta-analysis object (see Details).

param

Parameters for effect sizes (see Details).

package

Character string with name of R package used to create the meta-analysis object obj.

n.samples

Number of samples per study if meta-analysis had been performed with R package 'meta' or rma from R package 'metafor'.

sm

A character string indicating the summary measure used in primary studies.

transf

A logical indicating whether effect sizes are transformed or on the original scale. If transf = TRUE (default), effect estimates are expected to be on the log scale (for example, log odds ratios instead of odds ratios for sm = "OR").

Details

Creates a matrix with sampled effect sizes of primary studies (number of rows equal to the number of samples, number of columns equal to the number of studies in the meta-analysis).

Main input to this function is argument obj containing a meta-analysis object created with bugs from R package 'R2OpenBUGS', jags from 'R2jags', jags.samples from 'rjags', brm from 'brms', rma from 'metafor', or metabin, metacont or metagen from 'meta'.

Argument param corresponds to the effect size measures of the primary studies (for R packages 'R2OpenBUGS', 'R2jags', and 'rjags') or to the name of the column that contains the unique identification of each primary study in the data frame containing the results of primary studies used for meta-analysis ('brms' package). This argument is not required if the meta-analysis has been performed using R package 'meta' or 'metafor'.

Information of the R package used to conduct the meta-analysis can be provided in argument package. The value of package can be 'R2OpenBUGS', 'R2jags', 'rjags', 'meta', 'metafor' or 'brms'. This information is not required for an object created with 'meta', 'metafor' or 'brms'.

Argument n.samples contains the number of samples per study for meta-analyses created with 'meta' or 'metafor'. Default is 10000 samples.

Summary measure used in primary studies (argument sm) can be either "OR" (odds ratio), "RR" (risk ratio), "HR" (hazard ratio), "RD" (risk difference), "MD" (mean difference), "SMD" (standardised mean difference), "GEN_ratio" (generic ratio) or "GEN_diff" (generic difference). Does not need to be provided if the meta-analysis was performed with 'meta' or 'metafor'.

Value

A matrix containing sampled effect sizes (rows) for primary study (columns).

Author(s)

Bernardo Sousa-Pinto bernardo@med.up.pt

Examples


# Example with an object obtained using the 'R2OpenBUGS' package ("es",
# whose simulations on the effect sizes of primary studies are those
# of the "delta" parameter). If the object had been obtained using a
# different package, all remaining arguments would be the same and only
# the "package" argument would have a different input.

# In this example, argument \code{transf = TRUE} (default), as sampled
# effect sizes are log odds ratios.

load(url("https://raw.github.com/BernardoSousaPinto/metainc_extra_files/main/es.Rdata"))

sample <- getsamples(es, param = "delta", package = "R2OpenBUGS", sm = "OR")
sample


# Example using a dataset providing effect sizes for primary studies (yi)
# and respective variances (vi). A frequentist meta-analysis using the 'meta'
# package is conducted.

data("anticoagulation_df")
m1 <- meta::metagen(yi, sqrt(vi), sm = "OR", data = anticoagulation_df,
  studlab = LETTERS[1:18])
set.seed(1090) # Make sampled effect sizes reproducible
sample1 <- getsamples(m1)
sample1

if(requireNamespace("metafor")){
# Same samples of effect sizes using R package 'metafor' (must be installed)

m2 <- metafor::rma(anticoagulation_df, measure = "OR", slab = LETTERS[1:18])
set.seed(1090) # Make sampled effect sizes reproducible
sample2 <- getsamples(m2)
sample2

all.equal(sample1, sample2) # Only difference: package name
}


[Package metainc version 0.2-0 Index]