confMeta: Creating 'confMeta' objects

View source: R/confMeta.R

confMetaR Documentation

Creating confMeta objects

Description

Function to create objects of class confMeta. This is the main class within the package. For an overview of available methods run methods(class = "confMeta").

Usage

confMeta(
  estimates,
  SEs,
  study_names = NULL,
  conf_level = 0.95,
  fun,
  fun_name = NULL,
  w = NULL,
  MH = FALSE,
  table_2x2 = NULL,
  measure = NULL,
  method.tau.re = "REML",
  method.tau.hk = "REML",
  method.tau.het = "REML",
  adhoc.hakn.ci = "IQWiG6",
  ...
)

Arguments

estimates

A vector containing the individual effect estimates. These should be on a scale where they are approximately normally distributed (e.g., log odds ratios, log risk ratios, mean differences). Must be of the same length as SEs and coercible to type double.

SEs

The standard errors of the individual effect estimates. Must be of the same length as estimates and coercible to type double.

study_names

Optional vector of study identifiers. If NULL (the default) names ("Study 1", "Study 2", ...) are used. Otherwise a vector that can be coerced to type character. Must be of the same length as arguments estimates and SEs.

conf_level

The confidence level (numeric scalar between 0 and 1).

fun

A function that combines estimates and SEs into a combined p-value. The function must accept arguments estimates, SEs, and mu. Any additional arguments that fun accepts can be passed via .... See p_value_functions for supported methods.

fun_name

A character vector of length 1. Label for fun used in autoplot.confMeta. Defaults to the name of the function passed to fun.

w

Numeric vector of weights for the studies. Must be of the same length as estimates and SEs, finite, and non-negative. If NULL (the default), equal weights are assumed. Used by weighted p-value combination functions.

MH

Logical. If TRUE, the fixed-effect comparison method will use Mantel-Haenszel pooling instead of the standard inverse-variance method. Requires table_2x2 and measure to be provided. Default is FALSE.

table_2x2

A data frame containing the 2x2 contingency table data for Mantel-Haenszel pooling. Required if MH = TRUE. Must contain columns: ai (events in experimental), bi (non-events in experimental), ci (events in control), di (non-events in control), n1i (total experimental), and n2i (total control).

measure

A character string indicating the effect measure to be used for Mantel-Haenszel pooling (e.g., "OR", "RR", "RD"). Required if MH = TRUE.

method.tau.re

Character string indicating which between-study variance estimator to use for random-effects meta-analysis (e.g., "PM", "REML", "DL"). Defaults to "REML". See meta::metagen() for all available choices.

method.tau.hk

Character string indicating which between-study variance estimator to use for the Hartung-Knapp meta-analysis. Defaults to "REML".

method.tau.het

Character string indicating which between-study variance estimator to use for calculating the general heterogeneity statistics in heterogeneity. Defaults to "REML".

adhoc.hakn.ci

Character string indicating the variance correction method for the Hartung-Knapp confidence intervals (e.g., "IQWiG6", "HK"). Defaults to "IQWiG6". See meta::metagen() for choices.

...

Additional arguments passed to fun.

Value

An S3 object of class confMeta containing the following elements:

  • estimates, SEs, w, study_names, conf_level: Values used to build the object.

  • individual_cis: Matrix of Wald-type confidence intervals for each study.

  • p_fun: The p-value function used for combined inference.

  • joint_cis: Combined confidence interval(s). Calculated by finding the values where the p-value function is larger than the significant level (1 - conf_level).

  • gamma: The local minima within the range of the individual effect estimates. Column x refers to the mean \mu and column y contains the corresponding p-value.

  • p_max: The local maxima of the p-value function. Column x refers to the mean \mu and column y contains the corresponding p-value.

  • p_0: The value of the p-value at \mu = 0.

  • comparison_cis: Combined confidence intervals calculated with other methods. These can be used for comparison purposes. Currently, these other methods are fixed effect (IV or Mantel-Haenszel), random effects (IV), Hartung & Knapp, and Henmi & Copas.

  • comparison_p_0: The same as in element p_0 but for the comparison methods (fixed effect, random effects, Hartung & Knapp, Henmi & Copas).

  • heterogeneity: A data frame with columns Q (Cochran's Q), p_Q (p-value for Q), I2 (I^2), Tau (\tau), I2_lower, and I2_upper, computed using the estimator defined by method.tau.het.

  • table_2x2: The 2x2 table data frame (if provided), otherwise NULL.

Confidence intervals

Individual confidence intervals are calculated as:

x_i \pm \Phi^{-1}(1 - \alpha/2) \cdot \sigma_i

where x_i are the estimates, \sigma_i the SEs, and \alpha = 1 - \mathrm{conf\_level}.

Combined confidence intervals are found by inverting the p-value function, identifying all \mu where the p-value exceeds the significance level (1 - conf_level).

Also, the HK method uses adhoc.hakn.ci = "IQWiG6" by default, i.e., it uses variance correction if the HK confidence interval is narrower than the CI from the classic random effects model with the DerSimonian-Laird estimator (IQWiG, 2022).

See Also

p_value_functions, autoplot.confMeta

Examples

# Simulate effect estimates and standard errors
set.seed(42)
n <- 5
estimates <- rnorm(n)
SEs <- rgamma(n, 5, 5)
conf_level <- 0.95

# Construct a simple confMeta object using p_edgington as
# the p-value function
cm <- confMeta(
  estimates = estimates,
  SEs = SEs,
  conf_level = conf_level,
  fun = p_edgington,
  fun_name = "Edgington",
  input_p = "greater"
)
    
cm2 <- confMeta(
  estimates = estimates,
  SEs = SEs,
  conf_level = conf_level,
  fun = p_edgington_w,
  w = 1/SEs,
  fun_name = "Edgington (1/SE)",
  input_p = "greater"
)

# print the objects
cm
cm2

# Plot the objects
autoplot(cm, cm2, type = "p")                   # p-value function plot
autoplot(cm, cm2, type = "forest")              # forest plot
autoplot(cm, cm2, type = c("p", "forest"))      # both


confMeta documentation built on June 10, 2026, 1:06 a.m.