Changelog
Source:NEWS.md
ipw (development version)
New features
ipwtm():type = "all"now works forfamily = "multinomial"and"ordinal"(time-varying categorical exposures that switch back and forth).ipwtm():type = "all"now works forfamily = "survival", following Graffeo, Latouche, Geskus & Chevret (2018, Biometrical Journal): exposure events may recur, an Andersen-Gill Cox model is fitted on all rows, and each row’s probability uses the cumulative baseline hazard over its own interval.New
ipwprob(): inverse probability weights from probabilities you estimated yourself (for example with machine learning or SuperLearner), for point treatments or cumulated over time within subjects.ipwpoint(): new families for count exposures ("poisson","negbin") and skewed continuous exposures ("gamma","lognormal").Smooth terms (
s(),te(),ti(),t2()) in model formulas are fitted as generalized additive models with mgcv: inipwpoint()for the binomial, gaussian and poisson families, and inipwtm()for the binomial family.ipwpoint(): newestimandargument for a binomial exposure:"ATE"(default),"ATT"(effect in the treated) and"ATO"(overlap weights).Existing calls are unchanged: without smooth terms the models are still fitted with
glm(), andestimanddefaults to"ATE". A covariate nameds,te,tiort2is treated as an ordinary variable.New
ipwboot(): bootstrap standard errors and percentile confidence intervals for a whole weighted analysis, re-estimating the weights in each bootstrap sample (Austin 2016). Withid, whole subjects are resampled and each sampled copy gets a new identifier; optionalstrata; failed samples are recorded instead of stopping.print()andconfint()methods. The help pages and vignette describe, from the package’s simulation study, when the bootstrap helps (well-behaved weights) and when no standard error is reliable (extreme weights).
Documentation
- New vignette, “Inverse probability weighting with ipw” (
vignette("ipw")), covering every function, with the new models andipwboot()highlighted. - Bootstrap standard errors. The help pages of
ipwpoint()andipwtm()have a new “Standard errors” paragraph in Details and new examples: a bootstrap that re-estimates the weights and the marginal structural model in each bootstrap sample (ipwpoint()), and a cluster bootstrap that resamples patients and re-runs bothipwtm()calls for the HAART example (ipwtm()). Robust standard errors (svyglm(),cluster()) treat the weights as known and tend to be conservative; Austin (2016, doi:10.1002/sim.7084) recommends the bootstrap.
ipw 1.3.2
CRAN release: 2026-11-01
Bug fixes
-
ipwpoint():weights.truncwas wrong whenevertruncwas set. The lower and upper quantiles were recycled across rows, so every truncated weight was replaced by one of the two bounds. Weights are now clipped at thetruncand1 - truncquantiles, and weights between the bounds are left unchanged. -
ipwtm()withfamily = "multinomial"or"ordinal": predicted probabilities are now matched to the observed exposure by level name rather than by column position. 1.3.1 stopped with an error for a two-level exposure, or when an exposure level did not occur among the rows used to fit the models. -
ipwpoint()withfamily = "multinomial"now works for a two-level exposure; 1.3.1 stopped with an error (“Observed exposure levels do not match fitted probability levels”). - Added a test for unstabilized weights (no
numerator) withfamily = "multinomial"and"ordinal"inipwpoint(). These failed in 1.3.0 and were fixed by the 1.3.1 rewrite (#3, @adcascone). -
ipwtm()withtype = "first"andfamily = "multinomial"/"ordinal": a switch is again defined as the first record at any level other than the lowest level in the whole data set, as in ipw <= 1.2.1.1. In 1.3.1 the reference level was chosen separately for each subject.
Improvements
-
ipwtm()now checks that all model variables exist and contain no missing values, and that a binomial/survival exposure is coded 0/1, with clear error messages instead of errors from insideglm()/coxph(). -
ipwtm()withfamily = "survival"now stops with a clear message when a formula containsstrata(), which is not supported. - Fitted models returned in
num.mod/den.modno longer carry an inlined copy of the data in theircall, so printing them is readable again. -
ipwpoint()andipwtm()share one set of internal helpers for argument checks, formula construction, probability extraction and truncation. - Removed blanket
import()of whole packages; all calls usepkg::fun.methodsis no longer imported.
ipw 1.3.1
CRAN release: 2026-10-30
-
Core Refactoring (
ipwtm,ipwpoint,ipwplot,tstartfun):- Improved defensive input validation, parameter checking, and error messages across all core functions.
- Modernized formula construction (
as.formula()) to eliminate fragileeval(parse(text = ...))string manipulations. - Fixed variable symbol evaluation issues when passing variables as function arguments rather than raw names.
- Modularized
ipwtminto dedicated family modeling engines (binomial,survival,multinomial,ordinal,gaussian). - Replaced manual survival hazard step-differencing with continuous baseline hazard interpolation using
survival::basehazandstats::approx. - Refactored
tstartfunto use safe column evaluation and direct vector lag logic (c(-1, t[-length(t)])).
-
Test Suite Expansion:
- Upgraded
testthatsuite to 3rd edition specs, expanding coverage formultinomial,ordinal,gaussian, unstabilized models, weight truncation, and invalid parameter rejection.
- Upgraded