ipwtm(): type = "all" now works for family = "multinomial" and
"ordinal" (time-varying categorical exposures that switch back and forth).
ipwtm(): type = "all" now works for family = "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: in ipwpoint() for the binomial,
gaussian and poisson families, and in ipwtm() for the binomial family.
ipwpoint(): new estimand argument 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(), and estimand defaults to "ATE". A covariate named
s, te, ti or t2 is 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). With id, whole subjects are resampled and
each sampled copy gets a new identifier; optional strata; failed samples
are recorded instead of stopping. print() and confint() 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).
vignette("ipw")), covering every function, with the new models and
ipwboot() highlighted.ipwpoint() and
ipwtm() 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 both ipwtm() 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.ipwpoint(): weights.trunc was wrong whenever trunc was 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 the trunc and
1 - trunc quantiles, and weights between the bounds are left unchanged.ipwtm() with family = "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() with family = "multinomial" now works for a two-level
exposure; 1.3.1 stopped with an error ("Observed exposure levels do not match
fitted probability levels").numerator) with
family = "multinomial" and "ordinal" in ipwpoint(). These failed in
1.3.0 and were fixed by the 1.3.1 rewrite (#3, @adcascone).ipwtm() with type = "first" and family = "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.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 inside glm() / coxph().ipwtm() with family = "survival" now stops with a clear message when a
formula contains strata(), which is not supported.num.mod / den.mod no longer carry an inlined
copy of the data in their call, so printing them is readable again.ipwpoint() and ipwtm() share one set of internal helpers for argument
checks, formula construction, probability extraction and truncation.import() of whole packages; all calls use pkg::fun.
methods is no longer imported.data-raw/make-regression-fixtures.R).Core Refactoring (ipwtm, ipwpoint, ipwplot, tstartfun):
as.formula()) to eliminate fragile eval(parse(text = ...)) string manipulations.ipwtm into dedicated family modeling engines (binomial, survival, multinomial, ordinal, gaussian).survival::basehaz and stats::approx.tstartfun to use safe column evaluation and direct vector lag logic (c(-1, t[-length(t)])).Test Suite Expansion:
testthat suite to 3rd edition specs, expanding coverage for multinomial, ordinal, gaussian, unstabilized models, weight truncation, and invalid parameter rejection.