Skip to contents

Reconstructs each arm's mean and SD, including between-subgroup variation, and calls compute_es() for two explicitly selected arms. Subgroups must partition each arm at the same outcome/time without overlapping participants.

Usage

aggregate_es_subgroups(
  data,
  study_id,
  arm_id,
  subgroup_id,
  mean,
  sd,
  n,
  group1,
  group2,
  disjoint,
  outcome_id = NULL,
  time_id = NULL,
  source_id = NULL,
  correction = c("hedges_exact", "hedges_approx", "none"),
  variance_method = c("LS", "J2_LS", "JOINT_DELTA"),
  conf_level = 0.95
)

Arguments

data

Data frame with one row per subgroup within an arm/outcome/time.

study_id, arm_id, subgroup_id, mean, sd, n

Column names, quoted or unquoted, for study, arm, subgroup, mean, SD and sample size. Each subgroup requires finite numeric summaries, n an integer greater than 1 and SD nonnegative.

group1, group2

Explicit scalar arm labels; the contrast is group1 minus group2. Each study/outcome/time stratum must contain both selected arms.

disjoint

Must be explicitly TRUE. This declares both disjoint subgroups within arms and independent participants across the two selected arms. Overlap cannot be detected from summaries; use another design if present.

outcome_id, time_id

Optional column names separating outcome/time strata. Do not omit these if rows describe different outcomes or measurement times.

source_id

Optional globally unique source-row ID column; defaults to original row numbers. Supplied IDs preserve traceability across input reorderings.

correction, variance_method, conf_level

Passed to compute_es(). variance_method accepts LS, J2_LS or JOINT_DELTA; use JOINT_DELTA when subsequent SMD covariance construction is required.

Value

A mars_es object with original subgroup data in original_data, aggregation$arms containing reconstructed summaries, and aggregation$source_map linking source rows to arm and effect IDs. Unselected-arm rows are listed in aggregation$excluded_source_ids. effect_data retains one reconstructed comparison per effect for subsequent compute_es_covariance() calls. Covariance is not inferred by aggregation; repeated strata require explicit dependence and participant declarations.

Details

Let \(n_j\), \(m_j\), and \(s_j\) be the sample size, mean, and standard deviation of subgroup \(j\). The combined sample size, mean, and variance are $$n = \sum_j n_j, \qquad m = \frac{\sum_j n_j m_j}{n},$$ $$s^2 = \frac{\sum_j (n_j-1)s_j^2 + \sum_j n_j(m_j-m)^2}{n-1}.$$ Numeric validation applies to selected arms; unrelated arms are retained in the original data but excluded explicitly. Duplicate subgroup identifiers within a study/arm/outcome/time stratum are rejected.

References

Higgins, J. P. T., Li, T., and Deeks, J. J. (2019). Choosing effect measures and computing estimates of effect. In Cochrane Handbook for Systematic Reviews of Interventions (2nd ed., pp. 143–176), section 6.5.2.10. Wiley. doi:10.1002/9781119536604.ch6 .

Examples

arms <- data.frame(study = 1, arm = rep(c("T", "C"), each = 2),
                   subgroup = rep(1:2, 2), m = c(12, 14, 10, 11),
                   s = c(3, 4, 3, 2), n = c(20, 25, 18, 22))
aggregate_es_subgroups(arms, study, arm, subgroup, m, s, n,
                       "T", "C", disjoint = TRUE)$aggregation$arms
#>   effect_id study_id outcome_id time_id arm_id arm_key     mean       sd  n
#> 1       es1        1    overall overall      T   es1.1 13.11111 3.691035 45
#> 2       es1        1    overall overall      C   es1.2 10.55000 2.516102 40