Skip to contents

Design (default): computes information fractions within each trial from subgroup variances.

Usage

# S3 method for class 'interactmeta_da'
ifrac(x, ...)

# S3 method for class 'interactmeta_ad'
ifrac(x, ...)

# S3 method for class 'interactmeta_swada'
ifrac(x, ...)

ifrac(x, ...)

# Default S3 method
ifrac(
  x,
  vi = NULL,
  trial = NULL,
  modifier = NULL,
  subgroup = NULL,
  big_var = 100^2,
  contrast = "all",
  contrast_sep = "-",
  reference = NULL,
  include_combined = FALSE,
  include_interaction = FALSE,
  yi = NULL,
  ...
)

# S3 method for class 'data.frame'
ifrac(
  x,
  ifrac = NULL,
  fit = NULL,
  tau = NULL,
  tau_gamma = NULL,
  reference = NULL,
  trial = "study",
  modifier = NULL,
  subgroup = "level",
  ifrac_var = NULL,
  contrast_sep = "-",
  summary = FALSE,
  prob = 0.95,
  big_var = 100^2,
  contrast = "all",
  include_combined = FALSE,
  include_interaction = FALSE,
  yi = NULL,
  ...
)

# S3 method for class 'interactmeta'
ifrac(
  x,
  ifrac = c("interaction", "combined"),
  ifrac_var = NULL,
  summary = FALSE,
  prob = 0.95,
  reference = NULL,
  tau_sampling = c("grid", "posterior"),
  n_tau_samples = NULL,
  seed = NULL,
  ...
)

# S3 method for class 'interactmeta_overall_ifrac'
ifrac(x, ...)

Arguments

x

Effect estimates. A numeric vector, or a data frame or escalc object with columns yi and vi. If omitted, yi is used.

...

Further arguments passed to methods.

vi

Numeric vector. Variance of the subgroup estimate. Not used when the estimates are a data frame or escalc object.

trial

Trial identifier. A vector (same length as the estimates), or when the estimates are a data frame the name of the trial column (default "study").

modifier

Modifier (the two-level within-trial contrast). A vector of level labels (same length as the estimates), or when the estimates are a data frame the name of the modifier column (default "level", else a legacy "subgroup" column). A column name that is not in the data is an error.

subgroup

Deprecated alias for modifier; supplying it warns. modifier takes precedence when both are given.

big_var

Positive number. Variance used to impute a missing trial-by-subgroup cell (yi = 0, vi = big_var). For an escalc object, a row that already has the placeholder yi = 0 and vi = 8 keeps that estimate, and vi is replaced by big_var. Defaults to 100^2.

contrast

Either NULL (subgroup rows only, wide IF_<subgroup> columns), a character vector of length 2 giving the two subgroup labels to contrast within each trial (computed as label1 - label2, where label2 is the reference), or "all" (default) to add each non-reference subgroup vs the reference.

contrast_sep

String used between subgroup labels in the contrast row label. Defaults to "-".

reference

Optional. Used when contrast = "all". Comparisons are generated only between each non-reference subgroup and the reference subgroup (e.g. g2-g1, g3-g1, ...). If reference is NULL, the reference defaults to the first level of a factor modifier, otherwise the first label in sorted unique order. Can be either an integer index or a reference level label, which must be one of the observed modifier levels.

When supplied, extra rows per trial are added with subgroup labels paste0(label1, contrast_sep, label2), and yi/vi computed as yi1 - yi2 and vi1 + vi2. Missing trial-by-subgroup combinations use the imputed yi=0 and vi=big_var.

For a fitted interactmeta, reference may instead name the stored non-reference subgroup to return the pooled IF in that orientation, \(1-\omega\) (see reference in modifiers()).

include_combined

Logical. If FALSE (default), return subgroup rows only. If TRUE, append one precision-weighted combined row per trial with subgroup = "Combined".

include_interaction

Logical. If FALSE (default), return subgroup rows only while still using contrast to define the reference-centered IF_* design columns. If TRUE and contrast is not NULL, append interaction/contrast rows below subgroup rows.

yi

Either a numeric vector of subgroup effect estimates, or a data frame / escalc object containing columns yi and vi. When a data frame is supplied as x or yi, vi must not be passed separately; trial and modifier name columns (defaults "study" and "level").

ifrac

For pooling only: "interaction" (default) or "combined" ("overall" is accepted with a deprecation warning).

fit, tau, tau_gamma, ifrac_var, summary, prob

Pooling options when x is a interactmeta or design data with IF_* columns (fit or tau / tau_gamma required for data-only pooling).

tau_sampling

For Bayesian pooling: "grid" (default; DIRECT nodes on fit$support) or "posterior" (native marginal \(\tau\) draws).

n_tau_samples

With tau_sampling = "posterior", overrides options(interactmeta.ifrac.n_tau_samples): 0L = posterior median plug-in, n > 0 = Monte Carlo size.

seed

Optional integer; set.seed() before tau posterior sampling.

Value

For the design method, a tibble with one row per trial-by-subgroup combination (subgroup levels and contrast rows when requested), including study, level (a factor with the reference subgroup as the first level on subgroup rows), yi, vi, and information-fraction columns. Columns yi, vi, precision (when present), and all IF_<...> columns are numeric.

For pooling, a interactmeta_overall_ifrac object (draws with metadata), or a summary data frame when summary = TRUE.

Details

Each component precision is defined as 1 / vi.

By default (contrast = "all"), all non-reference-vs-reference contrasts are added per trial. Set contrast = NULL to return only subgroup rows with wide IF_<subgroup> columns (one fraction per subgroup label).

When contrast is provided, the information fraction for each comparison is computed as the non-reference subgroup precision divided by the total subgroup precision within the trial. By convention, the reference subgroup is the label after contrast_sep, i.e. in a label like "g2-g1", "g1" is the reference subgroup.

By default, components are the observed subgroup labels. When include_combined = TRUE, one precision-weighted combined row per trial is appended with level = "Combined" (contribution-weighted mean \(m_j\) on the chosen scale). When include_interaction = TRUE, contrast rows are stacked below subgroup rows with level labels like "g2-g1" (reference after contrast_sep), using yi and vi for the contrast estimate and variance. Wide columns IF_<non-reference> are filled on every row (no NA), plus precision, and a reference column (last column). For each non-reference subgroup k, IF_k is the trial-level information fraction \(\pi_j\). On combined and contrast rows, precision is the sum of subgroup precisions in the trial (or in that comparison for a single contrast).

Pooling

For a fitted interactmeta, or ifrac() data with IF_* columns, pass ifrac to pool trial-level fractions across studies. $$\bar{\omega} = \sum_j \pi_j w_j / \sum_j w_j.$$ With ifrac = "interaction" (default), \(w_j = 1/(\tau_\gamma^2 + \sigma_{Aj}^2 + \sigma_{Bj}^2)\) using the interaction-block SD \(\tau_\gamma\). With ifrac = "combined" (combined-block / intercept SD \(\tau\)), \(w_j = 1/(\tau^2 + \sigma_j^2)\) using the overall-block intercept SD \(\tau\) and combined sampling variance \(\sigma_j^2=\mathrm{Var}(m_j)=(1-\pi_j)^2\sigma_{Aj}^2+\pi_j^2\sigma_{Bj}^2\). On Bayesian CAMS, default pooling evaluates \(\bar\omega(\tau^{(k)})\) on the DIRECT support (tau_sampling = "grid", one value per row of fit$support, with quadrature weights .weight). Pass tau_sampling = "posterior" to draw \(\tau\) or \(\tau_\gamma\) from the native bayesmeta / bmr margin via options(interactmeta.ifrac.n_tau_samples): 0L is a posterior-median plug-in; positive n (default 1000L) enables Monte Carlo. Frequentist CAMS uses the fitted heterogeneity only.

When modifiers(), combined(), or interactions() use at_ifrac = NULL, they use the DIRECT grid (inner quadrature). Outer Monte Carlo over uncertain reporting \(\pi^\star\) applies only with reporting_if_draws() or an exogenous at_ifrac distribution; fit_reporting_if_draws() can combine tau-posterior draws of \(\bar\omega\) with that outer layer.

Options

interactmeta.ifrac.n_tau_samples

Only when tau_sampling = "posterior" (or n_tau_samples is set): default 1000L for marginal \(\tau\) Monte Carlo; 0L uses the native posterior median plug-in.

Examples

yi <- c(0.2, 0.1, 0.3, 0.15)
vi <- c(0.01, 0.04, 0.0225, 0.09)
trial <- c("A", "A", "B", "B")
level <- c("g1", "g2", "g1", "g2")

# Default: all non-reference vs reference contrasts (reference = first
# factor level, or first sorted label for character subgroups).
ifrac(yi = yi, vi = vi, trial = trial, modifier = level)
#> # A tibble: 4 × 7
#>   study level    yi     vi precision IF_g2 reference
#>   <chr> <fct> <dbl>  <dbl>     <dbl> <dbl> <chr>    
#> 1 A     g1     0.2  0.01       100     0.2 g1       
#> 2 A     g2     0.1  0.04        25     0.2 g1       
#> 3 B     g1     0.3  0.0225      44.4   0.2 g1       
#> 4 B     g2     0.15 0.09        11.1   0.2 g1       

# Subgroup rows only, wide IF_<subgroup> for every label
ifrac(yi = yi, vi = vi, trial = trial, modifier = level, contrast = NULL)
#> # A tibble: 4 × 6
#>   study level    yi     vi IF_g1 IF_g2
#>   <chr> <chr> <dbl>  <dbl> <dbl> <dbl>
#> 1 A     g1     0.2  0.01     0.8   0.2
#> 2 A     g2     0.1  0.04     0.8   0.2
#> 3 B     g1     0.3  0.0225   0.8   0.2
#> 4 B     g2     0.15 0.09     0.8   0.2

# Single contrast (g1 - g2, reference g2)
ifrac(
  yi = yi, vi = vi, trial = trial, modifier = level,
  contrast = c("g1", "g2")
)
#> # A tibble: 4 × 7
#>   study level    yi     vi precision IF_g1 reference
#>   <chr> <fct> <dbl>  <dbl>     <dbl> <dbl> <chr>    
#> 1 A     g1     0.2  0.01       100     0.8 g2       
#> 2 A     g2     0.1  0.04        25     0.8 g2       
#> 3 B     g1     0.3  0.0225      44.4   0.8 g2       
#> 4 B     g2     0.15 0.09        11.1   0.8 g2       

# Specify reference subgroup explicitly
ifrac(yi = yi, vi = vi, trial = trial, modifier = level, reference = "g1")
#> # A tibble: 4 × 7
#>   study level    yi     vi precision IF_g2 reference
#>   <chr> <fct> <dbl>  <dbl>     <dbl> <dbl> <chr>    
#> 1 A     g1     0.2  0.01       100     0.2 g1       
#> 2 A     g2     0.1  0.04        25     0.2 g1       
#> 3 B     g1     0.3  0.0225      44.4   0.2 g1       
#> 4 B     g2     0.15 0.09        11.1   0.2 g1       

# Append combined rows (one per trial)
ifrac(
  yi = yi, vi = vi, trial = trial, modifier = level,
  include_combined = TRUE
)
#> # A tibble: 6 × 7
#>   study level       yi     vi precision IF_g2 reference
#>   <chr> <chr>    <dbl>  <dbl>     <dbl> <dbl> <chr>    
#> 1 A     g1        0.2  0.01       100     0.2 g1       
#> 2 A     g2        0.1  0.04        25     0.2 g1       
#> 3 B     g1        0.3  0.0225      44.4   0.2 g1       
#> 4 B     g2        0.15 0.09        11.1   0.2 g1       
#> 5 A     Combined  0.18 0.008      125     0.2 g1       
#> 6 B     Combined  0.27 0.018       55.6   0.2 g1       

# Append interaction rows at the bottom
ifrac(
  yi = yi, vi = vi, trial = trial, modifier = level,
  include_interaction = TRUE
)
#> # A tibble: 6 × 7
#>   study level    yi     vi precision IF_g2 reference
#>   <chr> <chr> <dbl>  <dbl>     <dbl> <dbl> <chr>    
#> 1 A     g1     0.2  0.01       100     0.2 g1       
#> 2 A     g2     0.1  0.04        25     0.2 g1       
#> 3 B     g1     0.3  0.0225      44.4   0.2 g1       
#> 4 B     g2     0.15 0.09        11.1   0.2 g1       
#> 5 A     g2-g1 -0.1  0.05       125     0.2 g1       
#> 6 B     g2-g1 -0.15 0.112       55.6   0.2 g1       

if (FALSE) { # \dontrun{
library(interactmeta)
e <- escalc(measure = "IRR", yi = edss$yi, vi = edss$vi, data = edss)
d <- ifrac(e, reference = "Lower", include_interaction = TRUE)
fit <- cams(d, reference = "Lower")
forestplot(fit)
plot_contribution(fit)

# Pool across trials (interaction-IF, the default)
ifrac(fit)
ifrac(fit, ifrac = "combined")
} # }