smooth.ES.coefbootstrap

ES.coefbootstrap(nsim=1000, size=None, replace=False, prob=None, parallel=False, method='cr', seed=None, verbose=False)

Bootstrap the coefficient sampling distribution by refitting subsamples.

Mirrors R’s coefbootstrap.adam (R/adam.R:4850-5113). Draws nsim case-resamples of the in-sample series, refits the same model on each, and returns the empirical covariance / replicate matrix. The dispatch in vcov() and confint() forwards bootstrap=True here.

Parameters:
  • nsim (int) – Number of bootstrap replicates.

  • size (Optional[int]) – Subsample size per replicate. Defaults to floor(0.75 * nobs), matching R.

  • replace (bool) – Resample with replacement.

  • prob (Optional[NDArray]) – Sampling probabilities per observation (uniform if None).

  • parallel (Union[bool, int]) – True runs replicates in parallel via joblib.Parallel (cpu_count - 1 workers). An integer specifies the exact worker count. Requires the optional joblib dependency (pip install joblib or pip install "smooth[parallel]"); if joblib is not importable, a one-line warning is emitted and the call falls back to a serial loop.

  • method (str) – "cr" is case resampling (the implemented path). "dsr" (data-shape replication, R’s greybox::dsrboot) raises NotImplementedError.

  • seed (Optional[int]) – Seed for the numpy.random.Generator used to draw indices. Makes the result reproducible (same indices in serial and parallel modes — the optimiser is deterministic given a fixed sample).

  • verbose (bool) – Print a one-line progress message every 10% of replicates (in parallel mode, forwards verbose=10 to joblib.Parallel).

Returns:

Container with .vcov, .coefficients, .method, .nsim, .nsim_effective, .size, .time_elapsed, … Mirrors R’s "bootstrap" S3 class. .parallel reflects whether parallel execution actually ran (False when we fell back due to a missing joblib).

Return type:

smooth.adam_general.core.utils.bootstrap.BootstrapResult

Notes

Replicates whose refit fails (non-convergence, mismatched parameter count) are dropped silently; result.nsim_effective reports the count that contributed to the variance estimate.

Bootstrap on a model with external regressors (X) is not yet supported and will raise.

Examples

>>> m = ADAM(model="ANN").fit(y)
>>> b = m.coefbootstrap(nsim=50, seed=42)
>>> b.vcov.shape
(1, 1)

Parent Class: ES