Result of a bootstrap confidence interval computation.
BootstrapResult(
estimate,
se,
conf_low,
conf_high,
conf_level,
ci_type,
n_boot,
distribution,
)
Holds the point estimate, bootstrap standard error, and confidence interval for a Kaplan-Meier summary statistic. The full bootstrap distribution is retained for diagnostics or custom interval construction.
Attributes
estimate: float
-
Point estimate from the original (non-resampled) data.
se: float
-
Bootstrap standard error (standard deviation of the bootstrap distribution).
conf_low: float
-
Lower confidence limit.
conf_high: float
-
Upper confidence limit.
conf_level: float
-
Confidence level used for the interval.
ci_type: str
-
Type of confidence interval ("percentile", "normal", or "bca").
n_boot: int
-
Number of bootstrap replicates.
distribution: Array
-
The full bootstrap distribution (array of length
n_boot=).
Examples
Bootstrap a 95% confidence interval for the median survival time on the lung dataset:
import greenwood as gw
lung = gw.load_dataset("lung", backend="polars")
death = gw.Outcome.surv(time="time", event="status")
result = gw.bootstrap(death, statistic="median", n_boot=500, seed=0, data=lung)
result
BootstrapResult (n_boot=500, ci_type='percentile')
estimate se 0.95LCL 0.95UCL
310.000 23.330 283.475 363.000
Export as a single-row DataFrame:
result.to_frame(format="polars")
shape: (1, 4)| estimate | se | conf_low | conf_high |
|---|
| f64 | f64 | f64 | f64 |
| 310.0 | 23.330162 | 283.475 | 363.0 |
Methods
|
Name
|
Description
|
|
to_frame()
|
Export the result as a single-row DataFrame.
|
to_frame()
Export the result as a single-row DataFrame.
to_frame(
*,
format=None,
)
Parameters
format: str | None = None
-
Backend format:
"pandas", "polars", or "pyarrow". Default (None) uses the first available backend.
Examples
import greenwood as gw
lung = gw.load_dataset("lung", backend="polars")
death = gw.Outcome.surv(time="time", event="status")
result = gw.bootstrap(death, statistic="median", n_boot=500, seed=0, data=lung)
result.to_frame(format="polars")
shape: (1, 4)| estimate | se | conf_low | conf_high |
|---|
| f64 | f64 | f64 | f64 |
| 310.0 | 23.330162 | 283.475 | 363.0 |