Skip to content

Fractional Weighted Bootstrap

1packages dependsuggested by 7
51.6Kdownloads / year
94.5%test coverage
13/13flavors OK

Overview

About

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.

Changes in 1.0.0

New Features

  • Added a new confidence interval type for confint(), fwb.ci(), and summary(): "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 with cl, with the number of workers, and with verbose, and reproducing a parallel run required set.seed(###, "L'Ecuyer-CMRG") (or, with a cluster object, parallel::clusterSetRNGStream() instead of set.seed()). fwb() and vcovFWB() 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 to set.seed() is all that is needed, whatever cl, verbose, or RNGkind() are set to, and parallel::clusterSetRNGStream() no longer has any effect. See vignette("fwb-rep").
  • **This changes the bootstrap estimates when simple = TRUE** (the default for every wtype except "multinom"). Analyses that need to reproduce results from *fwb* 0.6.0 or earlier should install that version (e.g., using pak::pak("fwb@0.6.0")). Results with simple = FALSE are unchanged, so wtype = "multinom" continues to match boot::boot(., stype = "f") exactly. Note also that simple = TRUE and simple = FALSE no longer give the same estimates as each other, even for the weight types where they previously did.
  • **vcovFWB() no longer reproduces sandwich::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 in fwb() with simple = TRUE, so vcovFWB() gives the same results as vcov() applied to the output of fwb(., simple = TRUE) for every wtype, without holding the weights for all replicates in memory at once.
  • <fwb> objects no longer store the cl argument, since nothing about the backend is needed to recover the weights any more. Previously, a cluster object kept in the result made the object unusable after parallel::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 R is at least that many, fwb() and vcovFWB() now use each of them exactly once instead of sampling, and set R to 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 with strata (where the count is $\prod_s n_s^{n_s}$) and with cluster (where it is computed over clusters). It is the one respect in which wtype = "multinom" no longer matches boot::boot(., stype = "f"), which always samples; it reaches only very small samples, as $n = 6$ already has 46656 distinct samples.

Other changes

  • Added a CITATION file, so citation("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 NA when some of the bootstrap estimates are NA or non-finite.
  • BCa confidence intervals and fwb.array() now work regardless of simple, the use of parallel processing, or the presence of randomness in statistic. Previously, when simple = TRUE and the function supplied to statistic involved a random element, the weights could not be recovered: fwb.array() warned and returned weights that were not the ones used, and fwb.ci() and summary() 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 if cluster had not been supplied, returning weights unrelated to those used in the cluster bootstrap.
  • Fixed a bug in fwb.array() where strata was ignored unless it had been supplied as a factor, which also gave incorrect BCa confidence intervals for stratified bootstraps.
  • Fixed a bug in fwb.array() where the bootstrap weights were incorrect when wtype = "multinom" and simple = TRUE.
  • Fixed a bug in fwb() where stratified bootstrapping failed with an error when simple = TRUE (its default for every wtype except "multinom").
  • Fixed a bug in vcovFWB() that could give incorrect standard errors for lm models 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 match boot::boot(., stype = "f") exactly.
  • fwb() and vcovFWB() now throw an error when there is only one unit, or only one cluster, to resample. Previously fwb() failed with an obscure message for some weight types and returned all-zero standard errors for others, and vcovFWB() returned a matrix of zeros.
  • fwb() now checks that the function supplied to statistic can accept the dataset and the weights, and that its arguments do not share a name with one of fwb()'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 wrap statistic, such as *progressify*, working unchanged.
  • Confidence interval types that cannot be computed from the available number of bootstrap replications now say so. Previously, with R below what a type needs, "wald" and "norm" returned NA limits 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. Previously type = "all" at a small R failed on the first type it could not compute, returning nothing.
  • summary() and confint() now enforce BCa's requirements, as fwb.ci() always has. Previously, requesting ci.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 default na.action). The weights are now aligned with the rows the model used before the model is re-fit.
  • vcovFWB() is faster when drop0 is TRUE or NA for lm and glm models. Previously, these settings silently disabled the fast re-fitting paths used for these models, so every replicate was re-fit with a full update() call.
  • Fixed a bug in vcovFWB() where drop0 = NA produced an error ("cannot find valid starting values") for glm models. All three values of drop0 now give identical results for lm and glm models, 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() where fix = TRUE produced 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 fresh Rscript process).
  • Fixed a bug in vcovFWB() where drop0 = NA set the weights of units with nonzero weights to NA rather than those with weights of 0.
  • Fixed a bug in summary() where simultaneous p-values were assigned to the wrong estimates when ci.type = "wald" and one of the estimates had a variance of 0.
  • Fixed a bug in w_scale() (and w_std() with center = 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 specified parm.
  • w_std(), w_scale(), and w_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 in help("w_std")) whenever any weight was 0, i.e., with wtype = "multinom" or "poisson".
  • The w_*() functions can now be used inside statistic when cl is a cluster object; previously this failed with an error about the function not being found, because *fwb* was not attached on the workers.
  • w_cor() gains an na.rm argument, matching the rest of the w_*() functions.
  • vcovFWB() now requires R to be greater than 1; previously R = 0 produced an unrelated error from stats::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

CRAN checks
13OK
Slowest check: 4.2 min · r-oldrel-windows-x86_64
Status changes
  • 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
Advisories

none known

Documentation

In release 1.0.0
READMEYes · 1,136 wordsVignettesYes · 1 · staticNEWSYes · 100% structured · mentions 1.0.0Citation fileYes · cites a publicationWebsiteYes · pkgdown
Cites a JOSS paper
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

51.6K
CRAN downloads in the past year
Rank #1,984 · ~141/day · ~4.3K/mo
Daily download trend is not available in this view yet.
3.3K30 days
9.3K90 days
51.6K1 year
Compare downloads with other packages →
Also on1.5K r2u10 autocran

Repository

10Stars
0Forks
0Open issues
0Open PRs
0Releases
94Commits
1Commit identities
License file reads as GPL-2.0 · 94 commits · Last activity 2026-10-14 · 0% stars, 30d
Responsiveness
How these are sampled
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

2023-10-10 · 62026-09-14 · 10
PracticesBeta

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.

Continuous integration (1)
GitHub Actions
Docs source (4)
README.Rmdpkgdown

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)

CRAN release process (1)
CRAN-SUBMISSION
Lint, format, editor (2)
lintrRStudio project
How this is detected·Detection ruleset v3 (2026-09-26)
AI coding toolsBeta

This repository shows signs of AI coding tools.

  • Claude Codefirst seen 2026-05-28
    Named in .Rbuildignore: .claude, CLAUDE.md
    Named in .gitignore: CLAUDE.md
    Commits: at least 2 crediting it in the message
Models named in its commits
  • Claude Opus 52 commits · Aug 2026
Counts are commits, not lines of code. Commits by a tool's accounts count once across all of its accounts. Commits crediting it are the largest count among its credit lines, a minimum.How this is detected·Detection ruleset v4 (updated 2026-09-27)

Dependencies

Declared dependencies
18 external dependencies (excludes base and recommended)

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.

Depends (1)
R >= 4.1.0
Imports (8)
argparallelrlangpbapply (>= 1.7-2)genericsgraphicsstatsutils
LinkingTo (0)
none
Enhances (0)
none
Reverse dependencies
1direct
0indirect
Imports 1
Suggested by 7
Depends, Imports or LinkingTo, most downloaded first
Suggests, most downloaded first

Datasets

People & History

People (1)
Author, Maintainer since 0.1.0 (2022)
Releases (10)

Pick two releases to compare their code metrics.

  • 1.0.0Latest
    record
    2026-10-14 · current release · diff ↗
  • 0.6.0
    record
    2026-05-29 · diff ↗
  • R
    R 4.6.0 released · 2026-04-24
  • 0.5.1
    record
    2025-09-19 · diff ↗
  • 0.5.0
    record
    2025-07-08 · diff ↗ ·
    added 1 export
    fwb.array
  • 0.4.0
    record
    2025-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
  • R
    R 4.5.0 released · 2025-04-11
  • 0.3.0
    record
    2025-03-04 · diff ↗
  • R
    R 4.4.0 released · 2024-04-24
  • 0.2.0
    record
    2023-12-07 · diff ↗ ·
    added 2 exports
    get_fwb_wtype, set_fwb_wtype
  • 0.1.2
    record
    2023-10-02 · diff ↗
  • R
    R 4.3.0 released · 2023-04-21
  • 0.1.1
    record
    2022-10-26 · diff ↗
  • 0.1.0
    record
    2022-09-19
  • R
    R 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.

APA

Balamuta, J. J. (2026). R Observatory: Metrics for fwb version 1.0.0 [Data set]. HJJB, LLC. Data release v2026-10-19. https://doi.org/10.5281/zenodo.21843040

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.

Report a problem with this page →

Privacy choices

These apply to this browser and are stored on this device only. Nothing about your choice is sent to us.

Read the privacy policy