Skip to contents

The question MASMR answers

MASMR estimates associations between substantive predictors and effect sizes, while accounting for methodological predictors and the other substantive predictors. It fits the original effect sizes in a joint model:

y = M\gamma + X\beta + u + \varepsilon.

Here, methodology predictors are in M, substantive predictors are in X, u represents the selected heterogeneity structure, and \varepsilon has the sampling covariance supplied to MARS. The coefficients of interest are \beta. This is adjustment for measured covariates, not an instrumental-variable analysis or a guarantee of causal interpretation.

The methodology-only baseline helps assess what substantive predictors add. Both fits use the same analysis data and original outcome. The moderator lists define the fixed predictors; formula supplies the outcome, intercept convention, and random terms. Do not put the same term in both moderator lists.

Fit and interpret the joint model

library(mars)
fit <- masmr(
  data = teacher_expectancy,
  methodology_mods = "factor(tester)",
  substantive_mods = c("year", "weeks", "factor(setting)"),
  formula = yi ~ 1,
  studyID = "study", variance = "vi",
  varcov_type = "univariate", structure = "univariate",
  estimation_method = "MLE"
)
fit$substantive_coefficients
#>                   term    estimate   std_error    conf_low    conf_high
#> 1                 year -0.02000394 0.020960425 -0.06108562  0.021077740
#> 2                weeks -0.01170587 0.004714228 -0.02094559 -0.002466156
#> 3 factor(setting)indiv  0.24963638 0.171929124 -0.08733851  0.586611270
#>      p_value
#> 1 0.33989790
#> 2 0.01302466
#> 3 0.14650922
fit$substantive_test
#> $statistic
#> [1] 10.92988
#> 
#> $df
#> [1] 3
#> 
#> $p_value
#> [1] 0.01211112
#> 
#> $method
#> [1] "Model-based joint Wald chi-square test of substantive coefficients"

Each coefficient describes a substantive association conditional on tester and the other substantive variables. Factor coefficients compare levels with the reference level used by R. Confidence intervals describe uncertainty; a small p-value alone does not establish practical importance.

For a meaningful change in a continuous predictor, rescale its estimate and interval. For example, the following expresses the weeks association per ten weeks, holding year, setting, and tester constant:

per_ten_weeks <- subset(fit$substantive_coefficients, term == "weeks")
per_ten_weeks[c("estimate", "std_error", "conf_low", "conf_high")] <-
  10 * per_ten_weeks[c("estimate", "std_error", "conf_low", "conf_high")]
per_ten_weeks
#>    term   estimate  std_error   conf_low   conf_high    p_value
#> 2 weeks -0.1170587 0.04714228 -0.2094559 -0.02466156 0.01302466

substantive_test tests whether all substantive coefficients are zero jointly. A factor with multiple contrasts contributes multiple degrees of freedom. This model-based Wald chi-square test measures evidence for the block after accounting for methodology. It does not rank predictors or measure their causal importance. With few studies, asymptotic intervals and tests can be unreliable.

Compare the baseline and joint models

fit$baseline$fit_stats
#>      logLik      Dev      AIC      BIC     AICc
#> 1 -2.704763 15.40953 11.40953 14.24284 21.59134
fit$joint$fit_stats
#>     logLik      Dev      AIC      BIC     AICc
#> 1 2.327697 17.34461 7.344606 13.01124 80.14461

The joint model adds substantive predictors to the methodology-only baseline. Use maximum likelihood for likelihood comparisons involving different fixed predictors. REML is available for estimation, but comparing REML likelihoods across these two predictor sets is inappropriate.

LR <- 2 * (fit$joint$fit_stats$logLik - fit$baseline$fit_stats$logLik)
df_added <- ncol(fit$joint$design_matrix) - ncol(fit$baseline$design_matrix)
stopifnot(LR >= 0, df_added > 0)
data.frame(LR = LR, df = df_added,
           p_value = pchisq(LR, df_added, lower.tail = FALSE))
#>         LR df    p_value
#> 1 10.06492  3 0.01802227

This approximate likelihood-ratio comparison assumes identifiable nested models, satisfactory optimization, and the same observations and covariance structure. Check those conditions before interpreting it. Boundary heterogeneity estimates and small samples warrant additional care. AIC is another model-comparison summary, not a measure of a predictor’s importance. Changes in estimated heterogeneity are descriptive and are not automatically a proportion of variance caused or explained by the substantive predictors.

Why both predictor groups enter the joint model

Regressing the outcome on methodology and then regressing those residuals on the original substantive predictors does not generally reproduce joint regression. When methodology and substantive predictors correlate, the first regression can remove substantive signal. The joint model estimates their associations together and uses its own coefficient covariance for inference.

For example, with equally weighted centered predictors correlated at 0.8 and a substantive coefficient of 2, outcome-only residualization can return 2(1-0.8^2)=0.72. Joint regression recovers 2 in the corresponding noiseless example. Equivalence through partial regression requires residualizing both the outcome and substantive predictors with the same fixed weighting; see the Yule–Frisch–Waugh–Lovell theorem.

MASMR fits the original outcome jointly with both predictor groups. stage1 and stage2 are additional names for baseline and joint, respectively. adjusted_effect_name is unused and produces a warning if supplied; no adjusted outcome is created.

Multilevel and SMD workflows

Random terms are shared by the baseline and joint models:

fit_ml <- masmr(
  data = your_data, methodology_mods = c("risk_bias", "blinded"),
  substantive_mods = c("dose", "duration"),
  formula = yi ~ 1 + (1 | study/effect), studyID = "study",
  variance = "vi", varcov_type = "univariate", structure = "multilevel"
)

The SMD workflow also fits the original effect-size column in both models:

fit_smd <- masmr(
  data = your_data, methodology_mods = "risk_bias",
  substantive_mods = c("dose", "duration"), studyID = "study",
  effectID = "effect", sample_size = "n", effectsize_type = "smd",
  effectsize_name = "yi", variance = "vi", varcov_type = "univariate",
  structure = "UN"
)

Effect-category intercepts are part of the SMD design. A substantive predictor that merely duplicates those categories is not identifiable; use predictors that add independent information. Sampling covariance is not recalculated from residualized effects.

Inference and supported inputs

  • The substantive table uses model-based normal 95% intervals; the joint Wald test uses the matching model-based covariance. These are not robust intervals.
  • robustID and robust_args pass to both MARS fits. Requested robust results remain in fit$joint and its summary; they do not change the dedicated substantive table or its test.
  • Missing-data removal follows MARS. With missing="em", source predictors across both moderator blocks are completed once and shared by both models. Inference is conditional on that single completion, without imputation uncertainty. The shared record is available in fit$missing_data$em.
  • LASSO is rejected because the reported unpenalized inference does not account for selection. Highly correlated predictors may still yield wide intervals.
  • SMD user-defined weights are rejected rather than silently ignored. Supply appropriate sampling variances/covariances through the backend’s supported inputs.
  • Simple random terms are preserved. Create transformed random-slope variables in the data first; nested calls inside random terms are explicitly rejected.

The complete fits remain available for diagnostics and summaries:

summary(fit$joint)
summary(fit)

Define a substantive contrast under common methodology

A substantive coefficient is one possible target. Another is the difference between two substantive conditions evaluated under the same specified methodological conditions. Write the fitted mean as f(s, m). MASMR estimates f(s1, m) - f(s0, m) at a reference profile, or averages this difference over explicit target profiles with weights that sum to one. These weights define the scientific target and are distinct from the precision weights used in fitting.

The following example compares two versus one week of prior contact, capped at three weeks as in the teaching example. Tester awareness and administration format define methodology for this question. Neither profile is automatically called an ideal study.

d <- teacher_expectancy
d$contact3 <- pmin(d$weeks, 3)
d$tester <- factor(d$tester, levels = c("blind", "aware"))
d$setting <- factor(d$setting, levels = c("group", "indiv"))
common_fit <- masmr(
  d, methodology_mods = c("tester", "setting"),
  substantive_mods = "contact3", formula = yi ~ 1,
  studyID = "study", variance = "vi", varcov_type = "univariate",
  structure = "univariate", estimation_method = "REML"
)
#> Warning in return_estimates(q_f = q_f, q_r = q_r, estimated_pars =
#> optim_values[["par"]], : Hessian inversion failed: Hessian is not positive
#> definite.
scenarios <- list(one_week = data.frame(contact3 = 1),
                  two_weeks = data.frame(contact3 = 2))
reference <- data.frame(tester = "blind", setting = "group")
masmr_contrast(common_fit, scenarios, reference, inference = "mKH")
#> MASMR: substantive contrast under common methodology
#>              contrast   estimate std_error  conf_low   conf_high df     p_value
#>  two_weeks - one_week -0.1479896 0.0368934 -0.226626 -0.06935321 15 0.001133033
#>  inference level    scale outcome predictor_inference
#>        mKH  0.95 1.010329  effect observed_predictors
#> Target profiles: 1 ; weights treated as fixed.
#>   scenario flagged_target_weight
#>   one_week                     0
#>  two_weeks                     0

The second scenario is compared with the first. Supply all substantive raw variables, including variables held constant. Transformations are rebuilt using the fitted terms, so poly() bases and factor coding remain consistent.

Specify a distribution rather than a single profile

Here each observed effect record contributes equally to a fixed target methodological distribution. For studies contributing several records this is an effect-record distribution, not an equal-study distribution. Build a study-level or externally specified target explicitly when that is the intended question. Do not create a Cartesian product of marginal categories unless that joint target is scientifically justified.

target <- d[c("tester", "setting")]
standardized <- masmr_contrast(
  common_fit, scenarios, target,
  target_weights = rep(1, nrow(target)), inference = "mKH"
)
standardized$result
#>                       contrast   estimate std_error  conf_low   conf_high df
#> two_weeks two_weeks - one_week -0.1479896 0.0368934 -0.226626 -0.06935321 15
#>               p_value inference level    scale outcome predictor_inference
#> two_weeks 0.001133033       mKH  0.95 1.010329  effect observed_predictors
standardized$target
#> $outcome
#> [1] "effect"
#> 
#> $substantive
#> $substantive$one_week
#>   contact3
#> 1        1
#> 
#> $substantive$two_weeks
#>   contact3
#> 1        2
#> 
#> 
#> $methodology
#>    tester setting
#> 1   aware   group
#> 2   aware   group
#> 3   aware   group
#> 4   aware   group
#> 5   blind   group
#> 6   aware   group
#> 7   blind   group
#> 8   aware   group
#> 9   aware   group
#> 10  blind   indiv
#> 11  blind   group
#> 12  blind   group
#> 13  blind   indiv
#> 14  blind   indiv
#> 15  aware   group
#> 16  blind   group
#> 17  aware   group
#> 18  blind   group
#> 19  aware   group
#> 
#> $weights
#>  [1] 0.05263158 0.05263158 0.05263158 0.05263158 0.05263158 0.05263158
#>  [7] 0.05263158 0.05263158 0.05263158 0.05263158 0.05263158 0.05263158
#> [13] 0.05263158 0.05263158 0.05263158 0.05263158 0.05263158 0.05263158
#> [19] 0.05263158
#> 
#> $fixed
#> [1] TRUE
standardized$support$methodology_groups
#>   methodology_group n_records n_studies contact3_min contact3_max
#> 1     blind / group         6         6            0            3
#> 2     aware / group        10        10            0            3
#> 3     blind / indiv         3         3            1            2
standardized$support$flagged_share
#>    scenario flagged_target_weight
#> 1  one_week                     0
#> 2 two_weeks                     0

Both substantive conditions use exactly this distribution. The default assigns equal weight to the supplied rows, including repeated profiles. Weights are normalized and saved. Zero-weight rows are allowed, but still must be valid design rows. Missing or unknown factor levels produce errors. Target profiles and weights are treated as fixed; intervals do not account for uncertainty in estimated target weights or methodological ratings.

In an additive model the substantive difference is constant across methodology, so these two targets give the same contrast. Absolute target means can differ. When substantive-by-methodological interactions are justified, contrasts can also differ across targets. Declare those terms through interactions, using explicit : terms. The methodology and substantive lists retain their main terms. This keeps the methodology-only baseline distinct from the substantive interaction block.

set.seed(917)
sim <- data.frame(study = 1:80, S = rnorm(80),
                  M = factor(rep(c("a", "b"), 40)), vi = .05)
sim$yi <- .2 + .3 * sim$S + .2 * (sim$M == "b") +
  .4 * sim$S * (sim$M == "b") + rnorm(80, sd = .3)
interactive_fit <- masmr(
  sim, "M", "S", interactions = "S:M", formula = yi ~ 1,
  studyID = "study", variance = "vi", varcov_type = "univariate",
  structure = "univariate"
)
masmr_contrast(interactive_fit,
  list(lower = data.frame(S = -.5), higher = data.frame(S = .5)),
  data.frame(M = c("a", "b")), target_weights = c(.25, .75))
#> MASMR: substantive contrast under common methodology
#>        contrast estimate  std_error  conf_low conf_high  df      p_value
#>  higher - lower 0.676309 0.04470808 0.5886828 0.7639352 Inf 1.071275e-51
#>  inference level scale outcome predictor_inference
#>      model  0.95     1  effect observed_predictors
#> Target profiles: 2 ; weights treated as fixed.
#>  scenario flagged_target_weight
#>    higher                     0
#>     lower                     0

Inspect support before interpreting the comparison

masmr_support() accepts the same scenarios, methodology, and target weights. It reports categorical-combination counts, continuous ranges within categorical combinations, independent study counts, design leverage, and substantive information after methodological adjustment at the joint fitted weights. Numerically coded categories must be represented as factors for categorical checks. Study counts use studyID, not a potentially different robust-cluster ID.

Flags identify absent categorical combinations or values outside observed continuous ranges. A lack of flags does not prove multivariate overlap or causal exchangeability. Leverage describes distance in the fitted design; there is no validated universal cutoff. All requested weights remain in the result, including weights for flagged profiles. Changing or restricting the target requires a new explicit call and changes the scientific question.

Choose inference explicitly

inference = "model" uses normal intervals from the joint model covariance. "KH" and "mKH" use joint-fit residual scaling and residual degrees of freedom for independent univariate formula fits. They reject repeated-study and correlated-error settings. "robust" requires a fit made with robustID; it uses its selected robust covariance and calculates degrees of freedom for the actual contrast, including Satterthwaite inference when requested. No missing robust result is silently replaced with a model-based result.

The returned covariance includes the covariance between the two target means. The uncertainty of their difference is not the sum of their separate variances. These are pointwise confidence intervals for fitted mean contrasts, not prediction intervals for a new study. Multiple calls do not implement a familywise multiplicity correction.

The original summary(fit) coefficient table retains its documented model-based normal inference. Use the explicitly selected contrast result when reporting a reference-profile or standardized comparison. The contrast interface supports formula and outcome-aware multivariate fits. SMD-style fitting is supported. Outcome-specific contrasts require explicit outcome and measure metadata.

Relationship to response-surface meta-analysis

Rubin’s effect-size-surface perspective and Zhang et al.’s response-surface implementation motivate evaluating scientific relationships under stated design conditions. MASMR uses established joint meta-regression to define substantive comparisons, record a common methodological distribution, and expose their support and uncertainty. Equivalent specifications give equivalent estimates. The contrast calculation and partialling-out identity are established linear model results; the software does not claim a new estimator or automatic removal of methodological bias. Reference: Zhang et al. (2023), https://arxiv.org/abs/2308.13514.

Bound sensitivity to methodological response-surface departures

A substantive contrast can depend on an interaction or curvature that the observed studies cannot estimate reliably. masmr_sensitivity() keeps the scientific target fixed and examines explicitly bounded additional functions. This is not correction for arbitrary unmeasured confounding.

For a baseline design X, candidate departures Q, total covariance Omega and target rows L and K, the distortion row is D = L A Q - K, where A = (X' W X)^(-1) X' W and W = Omega^(-1). The corrected estimate at a specified departure coefficient gamma is L A y - D gamma. L A Q measures contamination of fitted coefficients; K describes how the departure contributes to the target itself. Pure methodological curvature can contaminate the fitted substantive coefficient even when it cancels from the target contrast.

A missing interaction, with scientifically described bounds

The following data are constructed. The numerical bounds illustrate an elicitation record; they are not evidence-based recommendations for real reviews.

sd <- data.frame(study = 1:18, S = rep(c(0, 1, 0), each = 6),
                 M = rep(c(0, 0, 1), each = 6), vi = .0075)
sd$yi <- .20 + .15 * sd$S - .05 * sd$M +
  rep(c(-.02, -.01, 0, 0, .01, .02), 3)
sf <- masmr(sd, "M", "S", formula = yi ~ 1, studyID = "study",
            variance = "vi", varcov_type = "univariate", measure = "SMD",
            structure = "univariate", tau2 = 0)
ss <- list(A = data.frame(S = 0), B = data.frame(S = 1))
departures <- masmr_departures(~ S:M)

# Endorsed hypothetical methodological shifts: A .2--.6 original scale
# points, B .6--1.2 points. Reference SD = 10. The DIFFERENCE in shifts,
# not their average, yields an interaction bound [0, .10].
bounds <- masmr_bound_difference(
  "S:M", shift_a = c(.2, .6), shift_b = c(.6, 1.2), divisor = 10,
  meaning = "Difference in assessment-related shifts: B minus A",
  units = "SMD per binary substantive-by-methodological contrast",
  justification = paste("Hypothetical expert-endorsed ranges on the same scale;",
                        "a fixed reference SD of ten; ordering must be justified"),
  source = "Constructed vignette elicitation, not an empirical finding",
  status = "elicited", analysis_scale = "standardized_mean_difference"
)
bounds$table
#>   term lower upper                                            meaning
#> 1  S:M     0   0.1 Difference in assessment-related shifts: B minus A
#>                                                   units
#> 1 SMD per binary substantive-by-methodological contrast
#>                                                                                                    justification
#> 1 Hypothetical expert-endorsed ranges on the same scale; a fixed reference SD of ten; ordering must be justified
#>                                                       source   status
#> 1 Constructed vignette elicitation, not an empirical finding elicited
#>                 analysis_scale
#> 1 standardized_mean_difference
bounds$calibration
#> $shift_a
#> [1] 0.2 0.6
#> 
#> $shift_b
#> [1] 0.6 1.2
#> 
#> $divisor
#> [1] 10
#> 
#> $rule
#> [1] "[B_lower - A_upper, B_upper - A_lower] / divisor"
sa <- masmr_sensitivity(
  sf, ss, data.frame(M = c(0, 1)), departures, bounds,
  target_weights = c(.25, .75), covariance = "known",
  total_covariance = diag(.0075, 18)
)
sa$result
#>   outcome estimate std_error point_low point_high  conf_low conf_high
#> B  effect     0.15      0.05      0.15      0.225 0.0520018 0.3229982
#>   max_abs_distortion undetectable_shift_bound bounded_normal_low
#> B              0.075                    0.075                 NA
#>   bounded_normal_high threshold interval_change_multiplier expanded_estimable
#> B                  NA         0                         NA              FALSE
#>   covariance interval_scope        inference_status
#> B      known continuous_box known_covariance_normal
sa$distortion
#>     S:M
#> B -0.75
sa$conditional_information
#>     S:M
#> S:M   0

There are no S=1, M=1 observations. The interaction is undetectable, but its consequences differ across targets. Use M=0 to obtain an insensitive contrast for this particular departure only. Use M=1 or the shared target to expose the assumption. In the example, the bounds produce a point-estimate range [.150, .225]. A symmetric [-.10, .10] interaction range instead gives [.075, .225]; its conservative 95% envelope includes zero.

masmr_bounds() accepts named lower and upper limits, their scientific meaning, coefficient units, analysis scale, rationale, source and status. Sources may be external paired-method studies, relevant calibration data, or structured expert elicitation. Alternatively, label a range stress_test. The software checks completeness and scale compatibility; it cannot certify scientific plausibility. Confidence limits from a calibration study are not automatically hard bounds. The fixed-class coverage statements do not propagate uncertainty in estimated bounds or apply to outcome-driven bound selection.

Continuous moderators need explicit units and domains. Bound an interpretable change across, for example, ten weeks, then translate it to the coefficient’s per-week units. Equivalent rescaling requires transforming the bounds as well. For several departures, this release supports rectangular boxes; scientifically coupled constraints require a future general constrained-set interface.

Univariate, multivariate, and multilevel inputs

The formula workflow accepts precomputed SMD, raw mean differences, log ratios, Fisher z and other registered effect measures. Supply measure explicitly for sensitivity analyses. The measure labels describe the analysis scale: OR, RR, HR, IRR, and ROM inputs must already be on their log scales; ZCOR inputs must already be Fisher transformed. No implicit transformation is performed. Raw MD requires units. Ordinary formula fitting accepts precomputed effects; sensitivity analysis requires explicit measure metadata.

The outcome-aware multivariate workflow is not limited to SMD. The following jointly models two outcomes on different analysis scales without averaging them. Sampling covariance is supplied in the original input row order, separately from between-study heterogeneity. One record per study/outcome is required for the UN/DIAG outcome backend; repeated effects require a suitable multilevel model.

set.seed(272)
mv <- data.frame(study = rep(1:30, each = 2),
                 endpoint = factor(rep(c("symptom", "remission"), 30)),
                 S = rep(rnorm(30), each = 2),
                 M = rep(rnorm(30), each = 2),
                 vi = rep(c(.04, .06), 30))
mv$yi <- .2 + .15 * mv$S + .1 * mv$M + rnorm(60, sd = .3)
V <- as.matrix(Matrix::bdiag(rep(list(matrix(c(.04, .01, .01, .06), 2)), 30)))
mvf <- masmr(
  mv, "M", "S", outcome = "endpoint", effectsize_name = "yi",
  measure = c(symptom = "SMD", remission = "OR"),
  studyID = "study", variance = "vi", varcov_type = "multilevel",
  sampling_covariance = V, structure = "UN", tau2 = diag(c(.08, .08))
)
masmr_contrast(mvf, ss, data.frame(M = 0))$result
#>           contrast   estimate  std_error    conf_low conf_high  df    p_value
#> remission    B - A 0.04483707 0.06511137 -0.08277888 0.1724530 Inf 0.49106169
#> symptom      B - A 0.10319241 0.06028142 -0.01495700 0.2213418 Inf 0.08692534
#>           inference level scale   outcome predictor_inference
#> remission     model  0.95     1 remission observed_predictors
#> symptom       model  0.95     1   symptom observed_predictors
mb <- masmr_bounds(
  lower = c("remission::S:M" = -log(1.2), "symptom::S:M" = -.10),
  upper = c("remission::S:M" = log(1.2), "symptom::S:M" = .10),
  meaning = "Differential methodological shift between substantive conditions",
  units = c("log OR per category contrast", "SMD per category contrast"),
  justification = "Illustrative stress-test ranges requiring calibration in a real review",
  source = "Constructed example", status = "stress_test",
  analysis_scale = c("log_odds_ratio", "standardized_mean_difference")
)
ms <- masmr_sensitivity(mvf, ss, data.frame(M = .5),
                       masmr_departures(~ S:M, by_outcome = TRUE), mb)
ms$result
#>             outcome   estimate  std_error    point_low point_high    conf_low
#> remission remission 0.04483707 0.06511137 -0.004808378 0.09448252 -0.13242432
#> symptom     symptom 0.10319241 0.06028142  0.075962800 0.13042202 -0.04218661
#>           conf_high max_abs_distortion undetectable_shift_bound
#> remission 0.2220985         0.04964545                        0
#> symptom   0.2485714         0.02722961                        0
#>           bounded_normal_low bounded_normal_high threshold
#> remission        -0.11237951           0.2020537         0
#> symptom          -0.02605924           0.2324441         0
#>           interval_change_multiplier expanded_estimable covariance
#> remission                          0               TRUE     fitted
#> symptom                            0               TRUE     fitted
#>           interval_scope inference_status
#> remission continuous_box      approximate
#> symptom   continuous_box      approximate
ms$baseline_contrast_covariance
#>              B            B
#> B 0.0042394908 0.0003028208
#> B 0.0003028208 0.0036338493

Each outcome gets its own intercepts, moderators, departure coefficients and bounds. masmr_contrast(..., outcome="symptom") selects one target; omitting it returns separate targets and their covariance. Cross-scale outcome averaging and nonlinear response-scale sensitivity targets are not implemented. Supply outcome and explicit measure metadata for outcome-specific targets. For ordinary multilevel fits, keep a formula such as yi ~ 1 + (1 | study) and supply the sampling covariance separately if sampling errors are correlated. A random study intercept does not supply that sampling covariance. Simultaneous UN outcome heterogeneity plus extra random terms is not an implemented adapter.

Inference modes and finite-grid refitting

  • covariance="known" requires the full known total covariance, including heterogeneity, in fit$analysis_data row order. Under normal errors, fixed targets and bounds, the continuous-box normal envelope has at least nominal pointwise coverage. Supplying known sampling variance alone is insufficient.
  • covariance="fitted" freezes fitted weights. Point ranges follow the fixed weighting calculation, but inference with estimated covariance is approximate.
  • covariance="refit" re-estimates heterogeneity at each explicitly supplied departure-grid row, preserving the original sampling covariance. It returns a finite-grid envelope. It does not claim to enclose continuum extrema.
# Symmetric stress test, deliberately distinct from the one-sided elicitation.
sb <- masmr_bounds(c("S:M" = -.1), c("S:M" = .1),
  meaning = "Differential assessment shift", units = "SMD per category contrast",
  justification = "Prespecified symmetric stress test", source = "Vignette",
  status = "stress_test", analysis_scale = "standardized_mean_difference")
grid <- matrix(c(-.1, 0, .1), ncol = 1, dimnames = list(NULL, "S:M"))
masmr_sensitivity(sf, ss, data.frame(M = 1), departures, sb,
                  covariance = "refit", grid = grid)$result
#>   outcome estimate std_error point_low point_high   conf_low conf_high
#> B  effect     0.15      0.05      0.05       0.25 -0.0479982 0.3479982
#>   max_abs_distortion undetectable_shift_bound bounded_normal_low
#> B                 NA                      0.1                 NA
#>   bounded_normal_high threshold interval_change_multiplier expanded_estimable
#> B                  NA         0                         NA              FALSE
#>   covariance interval_scope inference_status
#> B      refit    finite_grid      approximate

Normal model inference is available across the supported adapters. KH and modified KH require independent univariate records and a grid, because their residual scale changes with departures. Robust sensitivity requires refitting with an existing robust fit; its covariance and actual contrast degrees of freedom are recomputed per grid row. A component failure stops the envelope; failed rows are not silently discarded. Fixed-weight robust envelopes are not implemented. Numerical warnings from the fitting backend remain visible.

Reported intervals are pointwise unless adjustment="bonferroni" is selected for a returned multivariate outcome family. Practical estimated-covariance intervals remain approximate after multiplicity adjustment. The shorter bounded-normal benchmark is available for symmetric fixed-weight boxes; it uses established bounded-bias inference, not a new MASMR critical value. Null-direction bounds use exact vertex enumeration where feasible and explicitly report an enumeration limit otherwise. Numeric rank depends on declared scaling and tolerance; it is not a universal support score.

This implementation is a functional-misspecification sensitivity workflow on top of ordinary meta-regression. It cannot establish that methodology or causal bias has been completely removed. Its known-covariance checks and practical model comparisons do not replace a broad operating-characteristic study of estimated covariance, small samples, or departures outside the declared function class.

Shared predictor completion in MASMR

masmr(missing="em") uses the same EM preparation as mars(), but completes all substantive and methodological source predictors together once before either fit. It also includes scale predictors if supplied. Both models receive identical completed values. Interaction and transformation columns are computed from those values; they are not imputed as separate predictors.

set.seed(1030)
em_dat <- data.frame(study=seq_len(60), M=rnorm(60))
em_dat$S <- .5*em_dat$M + rnorm(60, sd=.8)
em_dat$yi <- .2 + .25*em_dat$S - .10*em_dat$M + rnorm(60, sd=.2)
em_dat$vi <- .04
em_dat$M[c(4,13,26,45)] <- NA_real_
em_dat$S[c(8,13,31,52)] <- NA_real_
em_fit <- masmr(em_dat, "M", "S", formula=yi~1, studyID="study",
  variance="vi", varcov_type="univariate", structure="univariate",
  measure="SMD", tau2=.02, missing="em")
#> Warning: EM uses deterministic single completion; downstream standard errors
#> and tests condition on completed moderators and do not account for imputation
#> uncertainty. Use multiple imputation with pooling for missing-data-adjusted
#> inference.
em_fit$substantive_coefficients
#>   term  estimate  std_error  conf_low conf_high      p_value
#> 1    S 0.2631199 0.04027923 0.1841741 0.3420658 6.472523e-11
em_fit$missing_data$em[c("applied","converged","completion_runs",
  "shared_across_models","inference","uncertainty_accounted")]
#> $applied
#> [1] TRUE
#> 
#> $converged
#> [1] TRUE
#> 
#> $completion_runs
#> [1] 1
#> 
#> $shared_across_models
#> [1] TRUE
#> 
#> $inference
#> [1] "conditional_single_completion"
#> 
#> $uncertainty_accounted
#> [1] FALSE
stopifnot(identical(em_fit$joint$data, em_fit$baseline$data))
# Original-order values and mask, before fitting removes or sorts records:
em_fit$missing_data$em$missing_mask
#>           M     S
#>  [1,] FALSE FALSE
#>  [2,] FALSE FALSE
#>  [3,] FALSE FALSE
#>  [4,]  TRUE FALSE
#>  [5,] FALSE FALSE
#>  [6,] FALSE FALSE
#>  [7,] FALSE FALSE
#>  [8,] FALSE  TRUE
#>  [9,] FALSE FALSE
#> [10,] FALSE FALSE
#> [11,] FALSE FALSE
#> [12,] FALSE FALSE
#> [13,]  TRUE  TRUE
#> [14,] FALSE FALSE
#> [15,] FALSE FALSE
#> [16,] FALSE FALSE
#> [17,] FALSE FALSE
#> [18,] FALSE FALSE
#> [19,] FALSE FALSE
#> [20,] FALSE FALSE
#> [21,] FALSE FALSE
#> [22,] FALSE FALSE
#> [23,] FALSE FALSE
#> [24,] FALSE FALSE
#> [25,] FALSE FALSE
#> [26,]  TRUE FALSE
#> [27,] FALSE FALSE
#> [28,] FALSE FALSE
#> [29,] FALSE FALSE
#> [30,] FALSE FALSE
#> [31,] FALSE  TRUE
#> [32,] FALSE FALSE
#> [33,] FALSE FALSE
#> [34,] FALSE FALSE
#> [35,] FALSE FALSE
#> [36,] FALSE FALSE
#> [37,] FALSE FALSE
#> [38,] FALSE FALSE
#> [39,] FALSE FALSE
#> [40,] FALSE FALSE
#> [41,] FALSE FALSE
#> [42,] FALSE FALSE
#> [43,] FALSE FALSE
#> [44,] FALSE FALSE
#> [45,]  TRUE FALSE
#> [46,] FALSE FALSE
#> [47,] FALSE FALSE
#> [48,] FALSE FALSE
#> [49,] FALSE FALSE
#> [50,] FALSE FALSE
#> [51,] FALSE FALSE
#> [52,] FALSE  TRUE
#> [53,] FALSE FALSE
#> [54,] FALSE FALSE
#> [55,] FALSE FALSE
#> [56,] FALSE FALSE
#> [57,] FALSE FALSE
#> [58,] FALSE FALSE
#> [59,] FALSE FALSE
#> [60,] FALSE FALSE
em_fit$missing_data$em$completed_predictors
#>              M           S
#> 1   1.11842821  1.99538946
#> 2  -0.07928996  1.47041199
#> 3   1.48112728  0.65710545
#> 4   0.27927857  0.50922989
#> 5   2.26309406  1.41330792
#> 6   2.07001276  1.96457193
#> 7   2.63272016  1.25163520
#> 8  -0.32249421 -0.15664302
#> 9   0.39943586  0.11430013
#> 10 -0.45747674  0.67154608
#> 11 -0.62328849 -0.87126664
#> 12 -0.25439159  1.68178339
#> 13 -0.11137236 -0.03377987
#> 14  1.17771088  2.00970217
#> 15 -0.20335753 -0.58391978
#> 16 -0.64027666 -1.30964613
#> 17  0.17837282  0.57961032
#> 18 -0.54769688 -0.13183125
#> 19 -0.59993416 -0.25394675
#> 20  0.21179313  0.23410732
#> 21  0.77709664 -0.71649182
#> 22  1.34238067  1.03885412
#> 23  0.75121782  1.10635312
#> 24 -0.10858484 -0.77981615
#> 25  1.54203194  0.98263000
#> 26  0.81414037  1.25269460
#> 27 -2.02128286 -1.64602045
#> 28  1.28185206  0.78366965
#> 29 -1.15272108 -1.31438819
#> 30 -0.70518346  0.34836553
#> 31  1.49680736  0.90210637
#> 32 -1.77759977 -0.49423774
#> 33  0.80225568 -1.04370751
#> 34 -1.32074739  0.36476313
#> 35 -0.48679659  0.46641711
#> 36 -1.53984929 -1.21696535
#> 37 -0.92829713 -1.06721050
#> 38 -1.71323722 -0.20133567
#> 39  0.17534830 -0.82520345
#> 40 -2.94867899 -1.56809719
#> 41  0.59375861  0.59047330
#> 42 -1.16940767 -1.10990301
#> 43 -0.16982486 -0.38797355
#> 44  1.35094961  0.66525266
#> 45  0.83966202  1.28817002
#> 46 -1.64244694 -0.52359583
#> 47 -1.20100172 -0.84227517
#> 48 -1.63875060 -2.37509127
#> 49 -0.32992997 -0.96266667
#> 50  0.52485030 -0.92098810
#> 51 -0.65254314 -2.04800864
#> 52 -2.58284553 -1.47206297
#> 53 -0.60782368 -0.45267721
#> 54  0.01857104 -0.91933914
#> 55 -0.13694281 -0.82375236
#> 56 -0.99251148 -0.18541561
#> 57 -0.31884052 -0.08287999
#> 58 -1.08219691  1.33801715
#> 59  1.10844969  0.01619091
#> 60 -0.84606420 -0.40231400
# Reproduce the joint fit directly with mars() on the same completion:
em_completed <- em_dat
em_completed[c("M","S")] <- em_fit$missing_data$em$completed_predictors
em_direct <- mars(em_completed, formula=yi~M+S, studyID="study",
  variance="vi", varcov_type="univariate", structure="univariate", tau2=.02)
stopifnot(isTRUE(all.equal(coef(em_direct), coef(em_fit$joint))))

The substantive coefficient compares a one-unit change in S at common M under the additive working surface. Its normal interval conditions on the one completed predictor dataset. The EM warning is intentional: this is neither multiple imputation nor a likelihood integrating over missing predictors. The fixed heterogeneity in this example isolates completion; applied reviews must justify their covariance assumptions.

missing_data$em records convergence and original/completed predictors, a missingness mask, original input study IDs, and row_order="original_input". Both fitted models carry the shared record. Subsequent sensitivity refits hold completed predictors fixed. Contrasts report predictor_inference="conditional_single_completion"; sensitivity results report the same label in inference_status, even with known total covariance. Support output has data_basis="completed_predictors": it describes geometry of completed data, not evidence that missing study characteristics were observed.

Missing continuous predictors are supported; missing categorical predictors, nonconverged EM models and unsupported within-study variation are rejected. Outcomes and sampling variances are not imputed. The imputation model does not automatically condition on outcome values, precision, or unlisted auxiliary variables. A common completed dataset ensures consistent fits but does not make the imputation model scientifically adequate or propagate its uncertainty. Use proper multiple imputation and pooling when missing-data-adjusted inference is required; integrated MI support is a separate development task.