bootstrap_ci: Bootstrap Confidence Intervals for Distribution Parameters

View source: R/bootstrap_ci.R

bootstrap_ciR Documentation

Bootstrap Confidence Intervals for Distribution Parameters

Description

Computes non-parametric percentile bootstrap confidence intervals for the parameters of the best-fit distribution in a fitverse object. Optionally also bootstraps confidence intervals for T-year return levels.

Usage

bootstrap_ci(fit,
             B              = 999L,
             conf           = 0.95,
             return_periods = NULL,
             progress       = NULL,
             seed           = NULL,
             verbose        = TRUE)

## S3 method for class 'fitverse_bootstrap'
print(x, ...)

Arguments

fit

An object of class "fitverse" as returned by fitverse(). The bootstrap uses the best-fit distribution and estimation method stored in fit$best_fit.

B

Integer: number of bootstrap replicates. Default 999. At least 199 is recommended; 1999 for publication-quality intervals.

conf

Numeric in (0, 1): confidence level. Default 0.95 (95% CI).

return_periods

Numeric vector of return periods for which bootstrap CIs on return levels should be computed. NULL (default) skips this step. Example: return_periods = c(10, 50, 100).

progress

Optional function of the form function(p) where p is a numeric value in [0, 1]. Called after every 10% of replicates. Useful for shiny progress bars. Default NULL.

seed

Integer or NULL: random seed for reproducibility. Default NULL (no seed set).

verbose

Logical: print a progress message? Default TRUE.

x

An object of class "fitverse_bootstrap".

...

Currently unused.

Details

Algorithm

The non-parametric percentile bootstrap proceeds as follows:

  1. Draw B bootstrap samples of size n with replacement from the observed data.

  2. Re-fit the same distribution and estimation method to each sample, using the same internal engine as fitverse().

  3. Collect the B \times k matrix of parameter estimates (where k is the number of parameters).

  4. For each parameter, report the \alpha/2 and 1 - \alpha/2 empirical percentiles of the bootstrap distribution as the lower and upper confidence bounds.

Replicates that fail to converge are excluded; a warning is issued if more than 10% fail.

Return-level CIs

When return_periods is supplied, the T-year return level is computed for each bootstrap replicate using return_level(), and the percentile CI is reported for each T.

Value

An S3 object of class "fitverse_bootstrap" with the following elements:

params_ci

Data frame with one row per parameter and columns: parameter, estimate, lower, upper, se_boot (bootstrap standard error).

return_level_ci

Data frame (or NULL if return_periods = NULL) with columns: T, return_level, lower, upper.

boot_params

Numeric matrix of dimension B_{eff} \times k: all successful bootstrap parameter estimates. Useful for plotting bootstrap distributions.

B

Integer: number of replicates requested.

B_eff

Integer: number of successful replicates.

conf

Numeric: confidence level.

dist_key

Character: distribution key.

method

Character: estimation method.

Author(s)

Karuna G. Reddy karuna.reddy@auckland.ac.nz
M. G. M. Khan mgm.khan@usp.ac.fj

References

Efron, B. and Tibshirani, R. J. (1993). An Introduction to the Bootstrap. Chapman and Hall, New York.

Davison, A. C. and Hinkley, D. V. (1997). Bootstrap Methods and Their Application. Cambridge University Press.

See Also

return_level for point estimates without CIs.
fitverse for the initial fitting step.

Examples


set.seed(42)
x <- rgamma(200, shape = 2, rate = 0.5)
fit <- fitverse(x, dists = "gamma", plot = FALSE, verbose = FALSE)

boot <- bootstrap_ci(fit, B = 499, conf = 0.95, seed = 1, verbose = FALSE)
print(boot)

# Parameter CI data frame
boot$params_ci

# With return-level CIs
boot2 <- bootstrap_ci(fit, B = 499, return_periods = c(10, 50, 100),
                      seed = 1, verbose = FALSE)
boot2$return_level_ci


FitVerse documentation built on Dec. 1, 2026, 1:07 a.m.