Skip to contents

Experimental serial cases bootstrap: sample people with replacement, copy their complete effective histories with fresh target/nuisance IDs, and rerun repair_refit(). Estimate uncertainty of the fitted procedure, including measurement-model estimation. General coverage validity remains unestablished; targeted simulation screens show condition-dependent performance.

Usage

repair_bootstrap(
  object,
  mlm_data,
  data,
  id = NULL,
  refitter = NULL,
  B = 1999L,
  seed = 1L,
  tolerance = 1e-06
)

Arguments

object

A converged repair() fit using one MLM.

mlm_data

Reference repeated-observation data, as a data frame or one-element list named like the fitted model. Retain original fitted row names. Rows excluded from the original MLM fit are filtered by those names.

data

Original unit-level data, including requested/excluded unit rows.

id

Structural ID column; defaults to the original ID column and must match it.

refitter

Optional deterministic function of one data frame returning a fitted lmer/lme model. Required for nonliteral control objects or unsupported formula/argument dependencies. Its reference replay is subject to the same checks.

B

Positive integer number of attempted resamples; default 1999. Failed attempts are retained and never replaced. One attempt is permitted for diagnostics, but inference requires at least two usable vectors.

seed

Integer between zero and .Machine$integer.max; default 1. Uses saved L'Ecuyer-CMRG streams, Inversion normals, and Rejection sampling. Caller RNG kind and .Random.seed are restored on success or error. Box-Muller and user-supplied caller RNGs are rejected before changing state because their hidden state cannot be restored from .Random.seed.

tolerance

Positive finite numerical tolerance for identity replay; default 1e-6. Identity/schema/scope checks are exact.

Value

A separate S3 repair_bootstrap result containing the original estimate and conditional coefficient table, a B-by-p coefficient matrix (failed rows are all NA), replicate diagnostics, source-ID draw indices/cohort, reference audit, static specification (formula text, effects, ID, measurement settings, structural backend and regularization controls), seed streams, and software versions. Replicate fitted models and copied raw datasets are not retained. The original fit is unchanged. Use repair_bootstrap_coefficients() and repair_bootstrap_diagnostics() for stable tables; coef(), vcov(), confint(), nobs(), summary() and print() are supported. See vignette("person-bootstrap", package = "repair"). For models fitted with repair_lmer_refitter(), replicate diagnostics contain an optimization list-column with the internal attempt history and selection.

Details

Supports the single-model scope of repair_refit(), including contained lmer nuisance effects and supported linear lme covariance structures. Measurement and analyzed cohorts must coincide. Reference replay and draw eligibility are checked before sampling. Each attempt samples N source IDs uniformly with replacement and refits measurement and structural models; no observations are resampled within a person. The reference cohort and its selection/missingness pattern define the sampling population.

Each attempt has a separate recorded stream, so fitting RNG use/failure in one attempt cannot change subsequent draws. Preflight has its own stream. Seeded runs share their first B attempts when extended to larger B in the same numerical environment. Cross-version/optimizer bitwise equivalence is not promised. Callbacks must be deterministic recipes as in repair_refit().

Errors invalidate the entire coefficient vector. Informational warnings and singular-but-usable lmer fits are recorded and retained. No trimming, silent omissions, or replacement bootstrap attempts are made. A recorded measurement recipe such as repair_lmer_refitter() may retry numerical optimization within an attempt; every internal fit is audited. Inference is withheld when any attempt fails unless allow_failed = TRUE is explicitly passed to an inference accessor; that changes the interpretation to conditional on successful replicates. It does not make failure selection ignorable.

vcov() uses the sample covariance of the same complete usable vectors for every term. confint() uses marginal percentile intervals with R quantile type 7. Bootstrap variance is not added to the original conditional variance. No bootstrap p-values, BCa/studentized/simultaneous intervals, parallelism, checkpoint/resume, stratification, or multiple-model sampling are provided. Small B is for exercising code; increase B and assess Monte Carlo stability before interpreting tails. Software correctness is not a coverage guarantee.

Examples

data(repair_example)
model <- lme4::lmer(score ~ day + (day | person), repair_example$repeated)
fit <- repair(re("day") ~ practice, model, repair_example$people, "person")
# Tiny B demonstrates the API, not adequate tail precision.
boot <- repair_bootstrap(fit, repair_example$repeated,
  repair_example$people, B = 3, seed = 41)
summary(boot)
#> REPAIR person bootstrap (experimental)
#> re("day") ~ practice 
#> People: 60 ; attempts: 3 ; usable: 3 ; failed: 0 
#>         term   estimate  std.error   conf.low  conf.high conf.level     method
#>  (Intercept) -0.7895289 0.17673487 -0.9561153 -0.6361082       0.95 percentile
#>     practice  0.1754854 0.02360676  0.1717858  0.2158065       0.95 percentile
#>  attempted usable failed conditional_on_success                     inference
#>          3      3      0                  FALSE Experimental person bootstrap
#>          3      3      0                  FALSE Experimental person bootstrap
#> Experimental person-level cases bootstrap; marginal percentile intervals; coverage not yet validated. 
#> Assess Monte Carlo stability before interpreting interval tails.
confint(boot, level = .90)
#>                    5 %       95 %
#> (Intercept) -0.9523322 -0.6491676
#> practice     0.1725522  0.2142561
#> attr(,"method")
#> [1] "percentile"
#> attr(,"attempted")
#> [1] 3
#> attr(,"usable")
#> [1] 3
#> attr(,"failed")
#> [1] 0
#> attr(,"conditional_on_success")
#> [1] FALSE
#> attr(,"inference")
#> [1] "Experimental person bootstrap"
repair_bootstrap_coefficients(boot, conf.level = .90)
#>          term   estimate  std.error   conf.low  conf.high conf.level     method
#> 1 (Intercept) -0.7895289 0.17673487 -0.9523322 -0.6491676        0.9 percentile
#> 2    practice  0.1754854 0.02360676  0.1725522  0.2142561        0.9 percentile
#>   attempted usable failed conditional_on_success                     inference
#> 1         3      3      0                  FALSE Experimental person bootstrap
#> 2         3      3      0                  FALSE Experimental person bootstrap
repair_bootstrap_diagnostics(boot)
#>   replicate usable    stage reason n_people n_measurement n_analyzed
#> 1         1   TRUE complete              60           592         60
#> 2         2   TRUE complete              60           580         60
#> 3         3   TRUE complete              60           609         60
#>   measurement_singular           controls preliminary_multiplier
#> 1                FALSE recorded_optimizer                   0.95
#> 2                FALSE recorded_optimizer                   0.95
#> 3                FALSE recorded_optimizer                   0.95
#>   final_multiplier preliminary_alpha final_alpha preliminary_criteria_met
#> 1             0.95                 3           3                       NA
#> 2             0.95                 3           3                       NA
#> 3             0.95                 3           3                       NA
#>   final_criteria_met preliminary_fallback final_fallback elapsed optimization
#> 1                 NA                   NA             NA   0.546             
#> 2                 NA                   NA             NA   0.469             
#> 3                 NA                   NA             NA   0.474             
#>   warnings messages
#> 1                  
#> 2                  
#> 3