Computes bootstrap-based confidence intervals for the parameters of a
fitted "brs" model by repeatedly simulating data from the fitted
model and re-estimating parameters. Only "brs" (fixed or
variable-dispersion) objects are supported; "brsmm" is not supported.
Arguments
- object
A fitted
"brs"object (fixed or variable dispersion).- R
Integer: number of bootstrap replicates (default 199).
- level
Numeric: confidence level (default 0.95).
- ci_type
Character: type of confidence interval. One of
"percentile"(default),"basic","normal", or"bca".- max_tries
Optional integer: maximum number of bootstrap attempts to obtain converged replicates. If
NULL, usesmax(3 * R, 50).- keep_draws
Logical: if
TRUE, stores successful bootstrap parameter draws in attribute"boot_draws".- x
Object returned by
brs_bootstrap.- ...
Ignored.
Value
A data frame with columns parameter, estimate
(original point estimate), se_boot (bootstrap standard error),
ci_lower, ci_upper, mcse_lower, mcse_upper,
wald_lower, wald_upper, and level. The attribute
"n_success" gives the number of replicates that converged.
Additional attributes include "R", "n_attempted",
"ci_type", and optionally "boot_draws".
Details
For each replicate, data are simulated via brs_sim using
the estimated coefficients (on the link scale) and the original
design. The model is then re-fitted with brs. Replicates
that fail to converge are discarded; if the number of successful replicates
is too low, a warning is issued. Intervals are the empirical quantiles of
the bootstrap distribution of each parameter.
See also
confint.brs for Wald intervals;
brs_sim for simulation; brs for fitting.
Examples
# \donttest{
dat <- data.frame(
y = c(
0, 5, 20, 50, 75, 90, 100, 30, 60, 45,
10, 40, 55, 70, 85, 25, 35, 65, 80, 15
),
x1 = rep(c(1, 2), 10),
x2 = rep(c(0, 0, 1, 1), 5)
)
prep <- brs_prep(dat, ncuts = 100)
#> brs_prep: n = 20 | exact = 0, left = 1, right = 1, interval = 18
fit <- brs(y ~ x1, data = prep)
boot <- brs_bootstrap(fit, R = 50, level = 0.95)
print(boot)
#> Bootstrap confidence intervals
#> Level: 0.95 | CI: percentile | Successful replicates: 50 / 50 | Attempts: 50
#>
#> parameter estimate se_boot ci_lower ci_upper mcse_lower mcse_upper
#> 1 (Intercept) 0.2550945 0.7907320 -1.133843 1.9053881 0.3600124 0.16466097
#> 2 x1 -0.2202075 0.4952859 -1.166506 0.5223341 0.0896141 0.07822265
#> 3 (phi) -0.3929198 0.3436550 -1.258389 0.1050310 0.1539971 0.13098474
#> wald_lower wald_upper level
#> 1 -1.4390802 1.9492691 0.95
#> 2 -1.2809288 0.8405139 0.95
#> 3 -0.9343818 0.1485422 0.95
# }
