
Alternative Estimation Frameworks with `mars`
mars
authors
2026-11-20
Alternative-Estimation-Frameworks.RmdThis vignette demonstrates three alternative estimation frameworks
available in mars:
- Bootstrap
- Jackknife (leave-one-cluster-out for multilevel models)
- Permutation
Bootstrap intervals use the empirical distribution of independent-unit refits. Jackknife inference uses a complete set of omissions and the full-data estimate; omission quantiles describe sensitivity. Permutations test a specified null by comparing observed and transformed statistics, and do not produce percentile CIs.
Data and Base Model
We use the bundled school dataset and a multilevel
model.
fit <- mars(
formula = effect ~ 1 + (1 | district/study),
data = school,
studyID = "district",
variance = "var",
varcov_type = "multilevel",
structure = "multilevel",
estimation_method = "MLE"
)
summary(fit)
#> Results generated with MARS:v 0.6.0.8
#> Friday, November 20, 2026
#>
#> Model Type:
#> multilevel
#>
#> Estimation Method:
#> Maximum Likelihood
#>
#> Coefficient covariance: gls
#> Optimizer convergence code: 0
#>
#>
#> Model Formula:
#> effect ~ 1 + (1 | district/study)
#>
#> Data Summary:
#> Number of Effect Sizes: 56
#> Number of Fixed Effects: 1
#> Number of Random Effects: 2
#>
#> Random Data Summary:
#> Number unique district: 11
#> Number unique study: 56
#>
#> Random Components:
#> term var SD
#> district 0.05774 0.2403
#> study 0.03286 0.1813
#>
#> Fixed Effects Estimates:
#> attribute estimate SE z_test p_value lower upper
#> (Intercept) 0.1845 0.08048 2.292 0.02191 0.02671 0.3422
#>
#> Model Fit Statistics:
#> logLik Dev AIC BIC AICc
#> -8.395 24.79 22.79 28.87 24.5
#>
#> Q Error: 578.864 (55), p < 0.0001
#>
#> I2 (General):
#> names values
#> district 92.11
#> study 86.92
#>
#> I2 (Jackson): 98.69621
#> I2 (Between): 86.37273
#>
#> Residual Diagnostics:
#> Diagnostic Value
#> Observations 56
#> Finite raw residuals 56
#> Mean raw residual -0.06446
#> SD of raw residuals 0.3258
#> Root mean squared residual 0.3293
#> Mean absolute residual 0.2632
#> Sum of squared Pearson residuals 96.8
#> Mean |studentized residual| 1.065
#> Maximum |studentized residual| 4.196
#> Proportion |studentized residual| > 2 0.1071
#> Proportion |studentized residual| > 3 0.03571
#>
#> Normality screen (Shapiro-Wilk, whitened residuals):
#> N W p-value
#> 56 0.9555 0.03766Bootstrap
set.seed(2026)
boot_repl <- replicate_bootstrap(
number_bootstraps = 5,
data = school,
formula = effect ~ 1 + (1 | district/study),
studyID = "district",
effectID = NULL,
sample_size = NULL,
variance = "var",
varcov_type = "multilevel",
structure = "multilevel",
estimation_method = "MLE"
)
boot_stats <- compute_alt_stats(boot_repl, type = "bootstrap")The summary component reports the original full-data
estimate, a separate replicate median, percentile 95% intervals, and
bootstrap_se: the sample SD of the finite bootstrap
estimates for each quantity. boot_repl retains the
empirical draws for coefficients and the extracted fit statistics and
heterogeneity quantities. Five draws illustrate the API; they are
insufficient evidence of stable tail quantiles.
summary(boot_stats)
#> Results generated with MARS: v 0.6.0.8
#>
#> Robust Method: Bootstrap
#> Number of Replications: 5
#> Successful: 5 ; Failed: 0
#> Interval method: percentile bootstrap
#> point_estimate ci_lower ci_upper bootstrap_se
#> (Intercept) 0.1845 0.1131 0.2608 0.0667
#> statistic.QE.value 578.8640 301.2747 738.1829 181.1682
#> statistic.QE.df 55.0000 52.3000 56.0000 1.7321
#> statistic.QE.p 0.0000 0.0000 0.0000 0.0000
#> statistic.QM.value 5.2528 3.6798 11.9205 3.7381
#> statistic.QM.df 1.0000 1.0000 1.0000 0.0000
#> statistic.QM.p 0.0219 0.0006 0.0588 0.0267
#> statistic.I2_within_1 92.1116 65.6981 95.4365 13.4866
#> statistic.I2_within_2 86.9221 82.3868 90.5024 3.7109
#> statistic.I2_jackson 98.6962 95.1169 99.2048 1.8540
#> statistic.I2_between 86.3727 71.7167 90.0773 8.1331
#> statistic.fit_stats.logLik -8.3949 -12.9406 4.4379 7.0903
#> statistic.fit_stats.Dev 24.7899 -0.8757 33.8811 14.1806
#> statistic.fit_stats.AIC 22.7899 -2.8757 31.8811 14.1806
#> statistic.fit_stats.BIC 28.8659 3.0570 38.0050 14.2412
#> statistic.fit_stats.AICc 24.5042 -1.0643 33.5646 14.1401
#> statistic.F_test.value 0.0890 0.0556 0.2252 0.0761
#> statistic.F_test.df1 1.0000 1.0000 1.0000 0.0000
#> statistic.F_test.df2 55.0000 52.3000 56.0000 1.7321
#> statistic.F_test.p 0.7666 0.6372 0.8149 0.0789
#> statistic.est_values.Tau_1 0.0577 0.0099 0.0728 0.0273
#> statistic.est_values.Tau_2 0.0329 0.0150 0.0442 0.0115
#> statistic.sd_1 0.2403 0.0967 0.2698 0.0751
#> statistic.sd_2 0.1813 0.1218 0.2098 0.0346
#> resample_median n_valid sufficient
#> (Intercept) 0.1981 5 TRUE
#> statistic.QE.value 568.7021 5 TRUE
#> statistic.QE.df 56.0000 5 TRUE
#> statistic.QE.p 0.0000 5 TRUE
#> statistic.QM.value 7.6596 5 TRUE
#> statistic.QM.df 1.0000 5 TRUE
#> statistic.QM.p 0.0056 5 TRUE
#> statistic.I2_within_1 91.4827 5 TRUE
#> statistic.I2_within_2 86.6188 5 TRUE
#> statistic.I2_jackson 98.5950 5 TRUE
#> statistic.I2_between 86.8213 5 TRUE
#> statistic.fit_stats.logLik -4.4146 5 TRUE
#> statistic.fit_stats.Dev 16.8292 5 TRUE
#> statistic.fit_stats.AIC 14.8292 5 TRUE
#> statistic.fit_stats.BIC 20.9584 5 TRUE
#> statistic.fit_stats.AICc 16.5092 5 TRUE
#> statistic.F_test.value 0.1296 5 TRUE
#> statistic.F_test.df1 1.0000 5 TRUE
#> statistic.F_test.df2 56.0000 5 TRUE
#> statistic.F_test.p 0.7202 5 TRUE
#> statistic.est_values.Tau_1 0.0518 5 TRUE
#> statistic.est_values.Tau_2 0.0281 5 TRUE
#> statistic.sd_1 0.2277 5 TRUE
#> statistic.sd_2 0.1676 5 TRUEThe quantiles component provides named quantile columns
directly:
boot_stats$quantiles["(Intercept)", c("2.5%", "50.0%", "97.5%")]
#> 2.5% 50.0% 97.5%
#> 0.1130715 0.1980713 0.2607931All coefficient distributions can also be visualized in a single base R figure, with one histogram panel per effect:
plot(boot_stats)
Jackknife
For multilevel models, jackknife leaves out one highest-level cluster
at a time (here: one district per replication). To keep the
vignette quick to compile, the example below uses only the first four
districts; the code is the same for the full dataset.
set.seed(2026)
school_jack <- subset(school, district %in% sort(unique(district))[1:4])
jack_repl <- replicate_jackknife(
data = school_jack,
structure = "multilevel",
formula = effect ~ 1 + (1 | district/study),
studyID = "district",
effectID = NULL,
sample_size = NULL,
variance = "var",
varcov_type = "multilevel",
estimation_method = "MLE"
)
jack_stats <- compute_alt_stats(jack_repl, type = "jackknife")Jackknife summaries compare leave-out fits with the original
full-data estimate. They report omission_min,
omission_max, max_abs_change, and descriptive
sensitivity_lower/sensitivity_upper quantiles.
omission_changes retains each signed difference from the
full-data fit, indexed by omitted unit. Inspect complete
and n_valid: when an omission fails, ranges describe the
available fits only.
jackknife_comparisons contains the estimate, SE, and
confidence limits from each omitted fit alongside their full-data values
and signed changes. The jackknife_uncertainty table reports
SE ranges and maximum changes in SEs and confidence limits. Model-based
and cluster-robust results are labelled separately; robust intervals
retain each fit’s degrees of freedom. level= controls the
confidence coverage for these comparisons. No additional sampling SE is
computed from the omission distribution.
summary(jack_stats)
#> Results generated with MARS: v 0.6.0.8
#>
#> Robust Method: Jackknife
#> Number of Replications: 4
#> Successful: 4 ; Failed: 0
#> Interval method: model-fit confidence intervals; leave-out sensitivity
#> Leave-out sensitivity: changes are relative to the full-data fit; ranges are descriptive.
#> point_estimate omission_median sensitivity_lower
#> (Intercept) 0.2335 0.2397 0.1457
#> statistic.QE.value 73.6776 48.9619 24.3643
#> statistic.QE.df 14.0000 10.0000 10.0000
#> statistic.QE.p 0.0000 0.0001 0.0000
#> statistic.QM.value 4.8364 3.9943 1.8248
#> statistic.QM.df 1.0000 1.0000 1.0000
#> statistic.QM.p 0.0279 0.0815 0.0029
#> statistic.I2_within_1 66.1729 62.8735 33.0026
#> statistic.I2_within_2 66.7270 66.4011 46.6930
#> statistic.I2_jackson 92.1176 91.4285 77.2687
#> statistic.I2_between 60.6399 61.9524 36.6844
#> statistic.fit_stats.logLik -1.7451 -0.9935 -2.3117
#> statistic.fit_stats.Dev 11.4903 9.9870 7.6866
#> statistic.fit_stats.AIC 9.4903 7.9870 5.6866
#> statistic.fit_stats.BIC 11.6144 9.1807 6.8802
#> statistic.fit_stats.AICc 19.9903 28.1921 26.6006
#> statistic.F_test.value 0.3602 0.4142 0.1738
#> statistic.F_test.df1 1.0000 1.0000 1.0000
#> statistic.F_test.df2 14.0000 10.0000 10.0000
#> statistic.F_test.p 0.5580 0.5513 0.3660
#> statistic.est_values.Tau_1 0.0282 0.0220 0.0123
#> statistic.est_values.Tau_2 0.0289 0.0273 0.0214
#> statistic.sd_1 0.1680 0.1467 0.1107
#> statistic.sd_2 0.1701 0.1646 0.1462
#> sensitivity_upper omission_min omission_max
#> (Intercept) 0.3044 0.1427 0.3049
#> statistic.QE.value 72.2757 23.6561 72.8798
#> statistic.QE.df 10.9250 10.0000 11.0000
#> statistic.QE.p 0.0079 0.0000 0.0086
#> statistic.QM.value 9.3928 1.8028 9.6766
#> statistic.QM.df 1.0000 1.0000 1.0000
#> statistic.QM.p 0.1770 0.0019 0.1794
#> statistic.I2_within_1 72.0017 30.8491 72.4733
#> statistic.I2_within_2 74.8219 45.6447 74.9550
#> statistic.I2_jackson 94.2747 76.1968 94.4293
#> statistic.I2_between 68.3292 34.8863 68.5956
#> statistic.fit_stats.logLik 0.1567 -2.4096 0.2410
#> statistic.fit_stats.Dev 12.6234 7.5180 12.8192
#> statistic.fit_stats.AIC 10.6234 5.5180 10.8192
#> statistic.fit_stats.BIC 12.0586 6.7117 12.2739
#> statistic.fit_stats.AICc 29.1758 26.5180 29.2091
#> statistic.F_test.value 0.9010 0.1701 0.9247
#> statistic.F_test.df1 1.0000 1.0000 1.0000
#> statistic.F_test.df2 10.9250 10.0000 11.0000
#> statistic.F_test.p 0.6850 0.3589 0.6879
#> statistic.est_values.Tau_1 0.0353 0.0120 0.0359
#> statistic.est_values.Tau_2 0.0368 0.0213 0.0372
#> statistic.sd_1 0.1879 0.1095 0.1895
#> statistic.sd_2 0.1919 0.1459 0.1930
#> max_abs_change n_valid n_requested complete
#> (Intercept) 0.0908 4 4 TRUE
#> statistic.QE.value 50.0216 4 4 TRUE
#> statistic.QE.df 4.0000 4 4 TRUE
#> statistic.QE.p 0.0086 4 4 TRUE
#> statistic.QM.value 4.8402 4 4 TRUE
#> statistic.QM.df 0.0000 4 4 TRUE
#> statistic.QM.p 0.1515 4 4 TRUE
#> statistic.I2_within_1 35.3238 4 4 TRUE
#> statistic.I2_within_2 21.0823 4 4 TRUE
#> statistic.I2_jackson 15.9208 4 4 TRUE
#> statistic.I2_between 25.7536 4 4 TRUE
#> statistic.fit_stats.logLik 1.9861 4 4 TRUE
#> statistic.fit_stats.Dev 3.9722 4 4 TRUE
#> statistic.fit_stats.AIC 3.9722 4 4 TRUE
#> statistic.fit_stats.BIC 4.9027 4 4 TRUE
#> statistic.fit_stats.AICc 9.2188 4 4 TRUE
#> statistic.F_test.value 0.5644 4 4 TRUE
#> statistic.F_test.df1 0.0000 4 4 TRUE
#> statistic.F_test.df2 4.0000 4 4 TRUE
#> statistic.F_test.p 0.1990 4 4 TRUE
#> statistic.est_values.Tau_1 0.0162 4 4 TRUE
#> statistic.est_values.Tau_2 0.0083 4 4 TRUE
#> statistic.sd_1 0.0585 4 4 TRUE
#> statistic.sd_2 0.0242 4 4 TRUE
#>
#> Leave-out SE and confidence interval comparisons:
#> parameter se_source original_se original_ci_lower original_ci_upper
#> (Intercept) model_based 0.1062 0.0254 0.4417
#> omission_se_min omission_se_max max_abs_se_change max_abs_ci_lower_change
#> 0.098 0.1357 0.0295 0.1092
#> max_abs_ci_upper_change n_valid n_requested complete
#> 0.1057 4 4 TRUEPermutation
Permutation inference currently supports independent univariate
formula models. Intercept-only tests change effect signs and require
symmetric errors under a zero-mean null. Global moderator tests permute
moderator blocks relative to effects and variances, require
assume_exchangeable=TRUE, and test all slopes jointly. They
are not partial tests conditional on nuisance moderators. Multilevel and
network permutation inference is rejected.
perm_repl <- replicate_permutation(
number_permutations = 19, future_seed = 2026L,
data = teacher_expectancy, structure = "univariate", formula = yi ~ 1,
studyID = "study", effectID = NULL, sample_size = NULL,
variance = "vi", varcov_type = "univariate", tau2 = 0
)
perm_stats <- compute_alt_stats(perm_repl)
summary(perm_stats)
#> Results generated with MARS: v 0.6.0.8
#>
#> Robust Method: Permutation
#> Number of Replications: 20
#> Successful: 20 ; Failed: 0
#> Interval method: none; null-statistic quantiles are not confidence intervals
#> observed_statistic p_value monte_carlo_se n_valid sufficient
#> (Intercept) 1.6553 0.25 0.0993 20 TRUEThis small example uses fixed zero heterogeneity to keep execution
quick. Each random test includes the observed fit in addition to the
requested transformations; p-values cannot be zero.
exact=TRUE enumerates small designs up to
max_exact. Any failed transformation withholds the affected
p-value. Permutation quantiles describe null statistics, not confidence
intervals.
Choosing precision and reading summaries
The default is 999 bootstrap samples or random permutations. Choose a
larger count when Monte Carlo uncertainty or repeated-seed tail
instability is too large. For a tail probability near .05, the
approximate Monte Carlo SE is sqrt(.05*.95/B), about .0069
for 999 independent draws. Defaults do not guarantee coverage for few
studies or dependent outcomes.
Replicate lists retain the original fit and method.
compute_alt_stats() detects the retained method. For
manually assembled lists, supply type= and the original fit
with original_fit=. point_estimate is the
full-data estimate; sensitivity_lower and
sensitivity_upper describe omission ranges. Use
level= to change bootstrap interval coverage or jackknife
sensitivity-range coverage, and quantiles= to change the
separate descriptive quantile table. Bootstrap SEs and intervals require
at least two finite draws and an 80% per-term success rate. Inspect
n_valid, sufficient, and failure counts before
interpreting bootstrap uncertainty; inspect complete for
jackknife omissions.
Factor levels, contrasts, and transformed-predictor bases retain
their original coordinates across samples. A sample that cannot estimate
the original design is recorded as a failure. LASSO resampling uses
mars_lasso() and its current controls, including
folds and selection in
lasso_args. Its summaries describe coefficient and
selection stability; they do not provide inferential confidence
intervals or jackknife standard errors for selected coefficients.