View source: R/multisite_ltg_smd.R
| multisite_ltg_smd | R Documentation |
Implements the multi-site workflow described in Section 7.3 and
illustrated in Example 3 (Section 6.3) of the paper (Many Labs 2
Anderson.1).
Each site is treated as a study sample, the cross-site pooled
distribution (or an external sample) is treated as the target
reference, and site-level Hedges's g and LTG-SMD estimates are
returned along with a meta-analytic comparison from metafor::rma().
multisite_ltg_smd(
data,
site_var,
group_var,
score_var = NULL,
items = NULL,
group_levels = NULL,
reliability_estimator = "alpha",
reference_strategy = c("pooled_across_sites", "external"),
reference_data = NULL,
min_n_per_group = 50L,
rho_external = NULL
)
data |
A data frame with one row per participant containing group, site, item-level, and (optionally) composite-score columns. |
site_var |
Character. Name of the site grouping variable. |
group_var |
Character. Name of the experimental-condition variable. |
score_var |
Optional character. Name of a precomputed composite
score column. If NULL, built from |
items |
Optional character vector of item column names. |
group_levels |
Optional named character vector with names "reference" and "focal". |
reliability_estimator |
Either "alpha" (default) or a function;
see |
reference_strategy |
One of "pooled_across_sites" (default;
uses all retained sites as the reference) or "external" (requires
|
reference_data |
Optional data frame; required when
|
min_n_per_group |
Integer. Minimum per-group sample size for a site to be retained. Defaults to 50. |
rho_external |
Optional named numeric vector with names "focal" and "reference" to override item-level reliability estimation. |
The site-level standard error for the LTG-SMD is approximated as
\widehat{\mathrm{SE}}_{\mathrm{LTG, site}} =
\sqrt{s^2_{1,\text{site}}/n_{1,\text{site}} +
s^2_{0,\text{site}}/n_{0,\text{site}}} \,/\, D,
treating the cross-site (or external) reference denominator D
as fixed. This approximation is reasonable when the reference sample
is large relative to each site, which is typical in coordinated
multi-site projects, but it understates uncertainty when the
reference is small. For a full reliability-propagated interval at
the site level, use ltg_smd_ci() with method = "bootstrap" on
each site separately.
An object of class "multisite_ltg_smd" containing:
Data frame of site-level estimates: site, n_focal, n_reference, hedges_g, ltg_smd, se_hedges, se_ltg.
List of pooled reference quantities (variances, reliabilities, true-score geometric SD).
Output of metafor::rma() for Hedges's g.
Output of metafor::rma() for the LTG-SMD.
Data frame summarizing the two meta-analytic pools side by side.
Character. Notes that the site-level SE for the LTG-SMD treats the reference denominator as fixed.
set.seed(2026)
gen_site <- function(site_name, n_per_cond = 15, shift = 0.3) {
true_ctrl <- rnorm(n_per_cond)
true_trt <- rnorm(n_per_cond)
ctrl <- data.frame(
site = site_name, condition = "control",
item1 = true_ctrl + rnorm(n_per_cond, sd = 0.6),
item2 = true_ctrl + rnorm(n_per_cond, sd = 0.6),
item3 = true_ctrl + rnorm(n_per_cond, sd = 0.6),
item4 = true_ctrl + rnorm(n_per_cond, sd = 0.6)
)
trt <- data.frame(
site = site_name, condition = "treatment",
item1 = true_trt + rnorm(n_per_cond, sd = 0.6) + shift,
item2 = true_trt + rnorm(n_per_cond, sd = 0.6) + shift,
item3 = true_trt + rnorm(n_per_cond, sd = 0.6) + shift,
item4 = true_trt + rnorm(n_per_cond, sd = 0.6) + shift
)
rbind(ctrl, trt)
}
ml_data <- do.call(rbind, lapply(
c("SiteA", "SiteB", "SiteC", "SiteD"), gen_site
))
result <- multisite_ltg_smd(
data = ml_data,
site_var = "site",
group_var = "condition",
items = paste0("item", 1:4),
reference_strategy = "pooled_across_sites",
min_n_per_group = 10
)
print(result)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.