Mendelian randomisation with prepared instruments
Explicit preparation
MR uses two aligned ordinary effect/standard-error data frames and a signed-LD matrix labelled in the same candidate order. It does not accept an LDlist, harmonize alleles, infer ancestry or infer sample overlap.
library(gbase)
library(gcorr)
prepared <- gcorr_prepare_mr(
statistics = list(exposure = exposure_summary, outcome = outcome_summary),
signed_ld = candidate_ld,
exposure = "exposure", outcome = "outcome",
reference_sample_size = 5000,
ancestry = c(exposure = "EUR", outcome = "EUR"),
reference_ancestry = "EUR",
effect_units = c(exposure = "SD", outcome = "SD"),
non_overlapping_samples = TRUE,
preparation = "gsmr2")Preparation records every candidate decision and every retained LD-pair decision. The result is serializable and contains no native pointer. GSMR uses an LD r-squared default of 0.1; GSMR2 preparation uses 0.05 and derives exposure p-values from effects and standard errors.
Focused estimators
gsmr <- gcorr_gsmr(prepared)
gsmr2 <- gcorr_gsmr2(prepared)
ivw <- gcorr_mr_ivw(prepared)
egger <- gcorr_mr_egger(prepared)
median <- gcorr_mr_weighted_median(prepared,
bootstrap_replicates = 1000, seed = 19)The thin dispatcher provides the same selection without a task contract:
gcorr(prepared, method = "gsmr")
gcorr(prepared, method = "weighted_median", seed = 19)GSMR and GSMR2 apply their distinct HEIDI procedures unless explicitly disabled. IVW, Egger and weighted median use the prepared set before HEIDI and require approximately independent instruments. Weighted median always requires an explicit seed. Reverse-direction analysis must prepare again from the original candidate summaries.
Effects retain outcome units per exposure unit. Instrument strength, HEIDI or agreement across estimators does not establish the exclusion restriction. The interface supports univariable, explicitly non-overlapping-sample analyses; it does not provide multivariable or overlapping-sample MR.