Fractional Weighted Bootstrap
Overview
An implementation of the fractional weighted bootstrap to be used as a drop-in for functions in the 'boot' package. The fractional weighted bootstrap (also known as the Bayesian bootstrap) involves drawing weights randomly that are applied to the data rather than resampling units from the data. See Xu et al. (2020) doi:10.1080/00031305.2020.1731599 for details.
New Features
- Added a new confidence interval type for
confint(),fwb.ci(), andsummary():"cheap", for the "cheap" confidence interval described by Lam (2022). This interval maintains nominal coverage even with few bootstrap replications (as low as one!).
Breaking changes
- **Bootstrap weights now depend only on the seed.** Previously, when
simple = TRUE, the weights were drawn inside each bootstrap replication and so depended on how the work was distributed: results changed withcl, with the number of workers, and withverbose, and reproducing a parallel run requiredset.seed(###, "L'Ecuyer-CMRG")(or, with aclusterobject,parallel::clusterSetRNGStream()instead ofset.seed()).fwb()andvcovFWB()now reserve one random number stream per replicate before any work is dispatched, and each replication draws its weights from its own stream. A plain call toset.seed()is all that is needed, whatevercl,verbose, orRNGkind()are set to, andparallel::clusterSetRNGStream()no longer has any effect. Seevignette("fwb-rep"). - **This changes the bootstrap estimates when
simple = TRUE** (the default for everywtypeexcept"multinom"). Analyses that need to reproduce results from *fwb* 0.6.0 or earlier should install that version (e.g., usingpak::pak("fwb@0.6.0")). Results withsimple = FALSEare unchanged, sowtype = "multinom"continues to matchboot::boot(., stype = "f")exactly. Note also thatsimple = TRUEandsimple = FALSEno longer give the same estimates as each other, even for the weight types where they previously did. - **
vcovFWB()no longer reproducessandwich::vcovBS()** when the same seed is set, and its results from earlier versions cannot be reproduced. Each replicate now draws its weights from its own random number stream, as infwb()withsimple = TRUE, sovcovFWB()gives the same results asvcov()applied to the output offwb(., simple = TRUE)for everywtype, without holding the weights for all replicates in memory at once. <fwb>objects no longer store theclargument, since nothing about the backend is needed to recover the weights any more. Previously, aclusterobject kept in the result made the object unusable afterparallel::stopCluster()or after being saved and reloaded.vignette("fwb-rep")has been rewritten around the new behavior. It no longer describes the several cases that used to require different treatment, and it explains how to reproduce results from earlier versions.- **The multinomial bootstrap is now exhaustive when it can be.** There are only $n^n$ distinct multinomial bootstrap samples of $n$ units, so when
Ris at least that many,fwb()andvcovFWB()now use each of them exactly once instead of sampling, and setRto that number (reporting this in a message). The estimates are then the exact bootstrap distribution rather than a sample from it, and they no longer depend on the seed. This applies withstrata(where the count is $\prod_s n_s^{n_s}$) and withcluster(where it is computed over clusters). It is the one respect in whichwtype = "multinom"no longer matchesboot::boot(., stype = "f"), which always samples; it reaches only very small samples, as $n = 6$ already has 46656 distinct samples.
Other changes
- Added a
CITATIONfile, socitation("fwb")now returns the *Journal of Open Source Software* article describing *fwb* (doi:10.21105/joss.08880). - Simultaneous inference with
ci.type = "perc"is much faster and now exact. Previously the confidence level was found by numerical search, which could return a band whose coverage fell short of the one requested; it is now computed directly.
Show all changes in 1.0.0Hide the rest of the changes in 1.0.0
- Simultaneous inference now produces an error rather than
NAwhen some of the bootstrap estimates areNAor non-finite. - BCa confidence intervals and
fwb.array()now work regardless ofsimple, the use of parallel processing, or the presence of randomness instatistic. Previously, whensimple = TRUEand the function supplied tostatisticinvolved a random element, the weights could not be recovered:fwb.array()warned and returned weights that were not the ones used, andfwb.ci()andsummary()refused to compute BCa intervals. Recovering the weights no longer involves replaying the random number stream, so these restrictions are gone. - Fixed a bug in
fwb.array()where the bootstrap weights were computed as ifclusterhad not been supplied, returning weights unrelated to those used in the cluster bootstrap. - Fixed a bug in
fwb.array()wherestratawas ignored unless it had been supplied as afactor, which also gave incorrect BCa confidence intervals for stratified bootstraps. - Fixed a bug in
fwb.array()where the bootstrap weights were incorrect whenwtype = "multinom"andsimple = TRUE. - Fixed a bug in
fwb()where stratified bootstrapping failed with an error whensimple = TRUE(its default for everywtypeexcept"multinom"). - Fixed a bug in
vcovFWB()that could give incorrect standard errors forlmmodels with a weight type that allows zeroes. - Weight generation with
wtype = "multinom"is faster, by up to 2x for small samples. Estimates are unchanged, so results still matchboot::boot(., stype = "f")exactly. fwb()andvcovFWB()now throw an error when there is only one unit, or only one cluster, to resample. Previouslyfwb()failed with an obscure message for some weight types and returned all-zero standard errors for others, andvcovFWB()returned a matrix of zeros.fwb()now checks that the function supplied tostatisticcan accept the dataset and the weights, and that its arguments do not share a name with one offwb()'s own (which would prevent them from ever being supplied through...). Functions with a...argument are exempt, since they can accept whatever they are given; this keeps packages that wrapstatistic, such as *progressify*, working unchanged.- Confidence interval types that cannot be computed from the available number of bootstrap replications now say so. Previously, with
Rbelow what a type needs,"wald"and"norm"returnedNAlimits without comment and the other types produced errors from deep inside the calculation ("subscript out of bounds", "missing value where TRUE/FALSE needed"). Only"cheap"can be computed from a single replication; the others require at least two. fwb.ci()now computes the interval types it can and skips the rest with a warning, rather than failing outright. Previouslytype = "all"at a smallRfailed on the first type it could not compute, returning nothing.summary()andconfint()now enforce BCa's requirements, asfwb.ci()always has. Previously, requestingci.type = "bca"with fewer bootstrap replications than units, or with clusters, produced an interval from an underdetermined calculation without any indication that it was not usable.- Fixed a bug in
vcovFWB()where an error was produced for any model whose fit dropped rows due to missing values in the model variables (e.g., under the defaultna.action). The weights are now aligned with the rows the model used before the model is re-fit. vcovFWB()is faster whendrop0isTRUEorNAforlmandglmmodels. Previously, these settings silently disabled the fast re-fitting paths used for these models, so every replicate was re-fit with a fullupdate()call.- Fixed a bug in
vcovFWB()wheredrop0 = NAproduced an error ("cannot find valid starting values") forglmmodels. All three values ofdrop0now give identical results forlmandglmmodels, as they should. vcovFWB()no longer fails for models that reject weights of 0 (e.g.,survival::coxph()) while it determines how to re-fit them.- Fixed a bug in
vcovFWB()wherefix = TRUEproduced an error whenever the covariance matrix it was meant to correct was not positive semi-definite. - Fixed a bug in
vcovFWB()where an error was produced in a session that had not yet used the random number generator (e.g., in a freshRscriptprocess). - Fixed a bug in
vcovFWB()wheredrop0 = NAset the weights of units with nonzero weights toNArather than those with weights of 0. - Fixed a bug in
summary()where simultaneous p-values were assigned to the wrong estimates whenci.type = "wald"and one of the estimates had a variance of 0. - Fixed a bug in
w_scale()(andw_std()withcenter = FALSE) where the variable was scaled by its uncentered second moment rather than by its weighted standard deviation as documented, when weights were supplied. - Fixed an incorrect error when using
confint.fwb()with incorrectly specifiedparm. w_std(),w_scale(), andw_center()now always return a vector as long as their input. Previously, units with weights of 0 or with missing values were dropped from the output, which made these functions fail inside a model formula (as demonstrated inhelp("w_std")) whenever any weight was 0, i.e., withwtype = "multinom"or"poisson".- The
w_*()functions can now be used insidestatisticwhenclis aclusterobject; previously this failed with an error about the function not being found, because *fwb* was not attached on the workers. w_cor()gains anna.rmargument, matching the rest of thew_*()functions.vcovFWB()now requiresRto be greater than 1; previouslyR = 0produced an unrelated error fromstats::cov().vcovFWB()no longer forwards...to the model refitting function; as documented, it is ignored.- Documentation fixes.
- New tests.
From NEWS.md in the release
Install
Health
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK13 OK2026-06-09
- WARNING12 OK, 1 WARNING2026-06-08
- OK12 OK2026-04-25
Show 1 earlier changeHide 1 earlier change
- WARNING11 OK, 3 WARNING2026-03-10
Documentation
- Help pages
- 11 (1 internal)includes a package overview page
- Examples that run
- 78%7 run in a plain check (4 of them under a condition) · 2 hold no code
- Exported functions with examples
- 100%
- Documented parameters
- 88%
- Return-value docs
- 100%
- Help pages citing references
- 45%
Downloads
Repository
- PRs merged (all time)
- not measured
- Median days to close, 50 most recently updated closed issues
- 560
- Median days to close, 50 most recently updated closed PRs
- not measured
Stars over time
Issues over time
Commits over time
8 development-tooling and community-health practices detected across 4 families in the upstream repository
Checks run against github.com/ngreifer/fwb on 2026-10-11.
GitHub Pages site last deployed 2026-08-28 · The repository has a site deploy workflow
pkgdown site last built 2026-08-28, before release 1.0.0 (2026-10-14)
This repository shows signs of AI coding tools.
- Claude Codefirst seen 2026-05-28Named in .Rbuildignore: .claude, CLAUDE.mdNamed in .gitignore: CLAUDE.mdCommits: at least 2 crediting it in the message
- Claude Opus 52 commits · Aug 2026
Dependencies
Installing fwb adds 5 packages (2 with compiled code, 1.5 MB of source tarballs). Heaviest: rlang 766 KB, cli 629 KB, arg 118 KB.
Code & Tests
Datasets
People & History
Pick two releases to compare their code metrics.
- 1.0.0Latest
- 0.6.02026-05-29 · diff ↗
- RR 4.6.0 released · 2026-04-24
- 0.5.12025-09-19 · diff ↗
- 0.5.0
- 0.4.02025-06-12 · diff ↗ ·
added 10 exports
w_center, w_cor, w_cov, w_mean, w_median, w_quantile, w_scale, w_sd, w_std, w_var - RR 4.5.0 released · 2025-04-11
- 0.3.02025-03-04 · diff ↗
- RR 4.4.0 released · 2024-04-24
- 0.2.0
- 0.1.22023-10-02 · diff ↗
- RR 4.3.0 released · 2023-04-21
- 0.1.12022-10-26 · diff ↗
- 0.1.02022-09-19
- RR 4.2.0 released · 2022-04-22
Package metadata
- First published
- 2022-09-19
- Total releases
- 10 / 4 yrs
- License
- GPL (>= 2) OSI
- Minimum R
- ≥ 4.1.0
- Bundled data
- 2.9 KB / 1 file
- Download size
- 588 KB
Cite
Cite this package
Run in R for the authors' entry:
citation("fwb")The package provides a citation file, so citation() returns the authors' own entry.
It points to 10.21105/joss.08880.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-19, which the citation names so these numbers can be found later. More on citing and the projects behind them.