Sequential Trial Emulation
Overview
Implementation of sequential trial emulation for the analysis of observational databases. The 'SEQTaRget' software accommodates time-varying treatments and confounders, as well as binary and failure time outcomes. 'SEQTaRget' allows to compare both static and dynamic strategies, can be used to estimate observational analogs of intention-to-treat and per-protocol effects, and can adjust for potential selection bias induced by losses-to-follow-up. (Paper to come).
- Drop the unused
doFutureanddoRNGdependencies. - Give an informative error when a model term is undefined for some rows (e.g.
log()of a non-positive value), naming the term, instead ofNROW(y) == nrow(x) is not TRUE. Such rows were silently dropped from the model matrix, despitena.action = na.pass, whichmodel.matrix()ignores. - Fix the end-of-follow-up
Trial-periods (Eligible)count including trial-periods that start too late to reach the window before the data end, which also inflatedCensoredand% Censored. Estimates are unchanged. - Fix
deviation.excused_colsexcusing deviations in every arm; column i now excuses only deviations by people followingtreat.level[[i]]. Deviation analyses are currently disabled, so no results change. - Fix the expansion reading
excused.colsthe opposite way to the weight models. Column i now excuses a switch away fromtreat.level[[i]]throughout (e.g.excusedZero = 1excuses a switch from 0 to 1), which changes everyexcused = TRUEanalysis. - Run the post-expansion excused-censoring coefficient test without
weight.upper = 1truncation. - Leave each subject's first row out of the pre-expansion treatment weight models. It has no previous treatment, so it was fitted under the first level of
treat.level, making estimates depend on that order. This shifts pre-expansion weighted estimates, most for excused censoring. - Fix subgroup risks, survival curves and hazard ratios being standardized over the whole population rather than the subgroup; each subgroup's results now equal an analysis of that subgroup alone. Results without
subgroupare unchanged. - Fix subgroup bootstrap results being matched by position rather than by name, which mixed up subgroups when a resample missed one. Such resamples are now left out of that subgroup's confidence intervals, with a warning.
- Fix the excused-censoring weights, which depended on the order of
treat.leveland, for post-expansion weights, were wrong by default (only the first arm was converted to the probability of remaining uncensored). SEQuential()now restores the caller'sfutureplan on exit, including on error, rather than resetting it to"sequential", and no longer registers a globalforeachbackend.- Fix
SEQuential()converting adata.framepassed asdatainto adata.tablein the caller's environment.
Show all changes in 1.4.5Hide the rest of the changes in 1.4.5
- Fix
SEQuential()printing "Creating Survival Curves for 1" (or for each subgroup) withverbose = FALSEwhenkm.curves = TRUE. - Fix the expansion failing on column names containing
"_bas"or"_sq"other than at the end (e.g.bmi_baseline); the indicators are now matched only as a suffix. - Fix the multinomial treatment model (
multinomial = TRUE), which was fit one-vs-rest but predicted with a softmax, biasing the weights; it is now fit as baseline-category logits. This changes weighted multinomial analyses with three or more treatment values. - Fix the treatment weights being inverted when
treat.levelis notc(0, 1)or whenmultinomial = TRUE. Binary analyses with the defaulttreat.levelare unchanged. - Fix transformed terms such as
log(x)being replaced by the raw variable in the weight models and some outcome predictions; only formulas of bare variable names now take the fast model-matrix path. - Fix the default outcome model dropping every fixed covariate, not just the subgroup variable, when
subgroupis set. This changes subgroup estimates that use the default outcome model. - Stop converting numeric
fixed.colsto factors, so continuous covariates such as age enter the models as a single term (a 0/1 covariate's coefficient is now named e.g.sexrather thansex1). **Integer-coded categorical fixed covariates (e.g. region coded 1-5) must now be supplied as factor or character columns.** - Validate in
SEQopts()thatcovariates,cense.numerator,cense.denominator,visit.numeratorandvisit.denominatorare single formula strings, and thatnumerator/denominatorare non-empty. These are scalar by construction - they are tested downstream withis.na()and||, which errors with'length = 2' in coercion to 'logical(1)'on a vector, ormissing value where TRUE/FALSE neededon a zero-length value, several frames from the argument that caused it. The error now names the offending argument at the point it is supplied.numeratoranddenominatormay still be a character vector with one formula pertreat.level, which is validated againsttreat.levelas before. - Allow a flexible function of time for the baseline hazard in the weight models through
weight.splineandweight.spline.dfinSEQopts(). The default weight models are quadratic in time -followup,followup_sq,trialandtrial_sqwhenweight.preexpansion = FALSE, the time column and its square whenweight.preexpansion = TRUE- which only allows the hazard of treatment to rise or flatten off. Withweight.spline = TRUEeach of those quadratics is replaced by a natural cubic spline basis (splines::ns()) withweight.spline.dfdegrees of freedom (default4, i.e. 3 interior knots at quantiles), so the baseline hazard can take a flexible shape over follow-up. This covers the treatment weight models and, where specified, thecenseandvisitmodels, under both settings ofweight.preexpansion. Weight models supplied throughnumerator,denominator,cense.numerator,cense.denominator,visit.numeratororvisit.denominatorare left as written, sons()terms can also be placed by hand for finer control. - Fix
ns(x, df = N)terms in any model formula silently using a different spline basis when fitting and when predicting.splines::ns()recomputes its knots from whatever rows it is passed, and the weight models are fit on one row subset (e.g. the denominator model excludesfollowup == 0) and then used to predict over another, so the knots - and hence the basis - differed between the two, and differed again in each bootstrap resample. Knots are now fixed from the full data the model is fit on before fitting, for the outcome, treatment weight, censoring and visit models alike, so the basis is identical at fit and prediction time and constant across resamples. Previously this affected only user-suppliedns()terms; a spline onfollowupin a post-expansion weight model changed weights by up to 0.21 in the package's own example data. Formulas that already give explicitknots/Boundary.knotsare unchanged, as are terms whose variable is absent or non-numeric.
From NEWS.md in the release
Install
Health
- OK13 OK2026-09-08
- ERROR12 OK, 1 ERROR2026-09-07
- OK13 OK2026-08-05
- NOTE12 OK, 1 NOTE2026-08-01
- OK14 OK2026-03-10
Documentation
- Help pages
- 69 (49 internal)includes a package overview page
- Examples that run
- 0%1 only when donttest examples are enabled (R CMD check --as-cran)
- Exported functions with examples
- 7%
- Documented parameters
- 100%
- Return-value docs
- 100%
- Help pages citing references
- 0%
Downloads
Repository
- PRs merged (all time)
- 97%
- Median days to close, 50 most recently updated closed issues
- 1
- Median days to close, 50 most recently updated closed PRs
- 0
Stars over time
Forks over time
Releases over time
Issues over time
PRs over time
Commits over time
8 development-tooling and community-health practices detected across 6 families in the upstream repository
Checks run against github.com/causalinference/seqtarget on 2026-10-21.
The R CMD check workflow runs on Linux, macOS and Windows, and on R-devel
GitHub Pages site last deployed 2026-10-13 · The repository has a site deploy workflow
pkgdown site last built 2026-10-13
Show all practicesHide 2 practices
Dependencies
Installing SEQTaRget adds 42 packages (21 with compiled code, 53 MB of source tarballs). Heaviest: BH 14 MB, stringi 11 MB, ggplot2 6.0 MB.
Code & Tests
Datasets
People & History
Pick two releases to compare their code metrics.
- 1.4.5Latest
- 1.4.4
- 1.4.3
- 1.4.22026-05-21 · diff ↗
- RR 4.6.0 released · 2026-04-24
- 1.4.12026-03-31 · diff ↗
- 1.3.62026-02-16 · diff ↗
- 1.3.52026-02-05 · diff ↗
- 1.3.42026-01-23 · diff ↗
- 1.3.32026-01-08 · diff ↗
- 1.3.22025-11-10 · diff ↗
- 1.3.02025-11-06 · diff ↗
- 1.1.12025-10-27 · diff ↗
- 1.0.12025-10-01 · diff ↗
- 1.0.02025-09-17 · diff ↗
- 0.13.12025-09-15
Show 1 earlier eventHide 1 earlier event
- RR 4.5.0 released · 2025-04-11
Package metadata
- First published
- 2025-09-15
- Total releases
- 15 / 1 yrs
- License
- MIT + file LICENSE OSI
- Minimum R
- ≥ 4.1
- Bundled data
- 1.6 MB / 3 files
- Download size
- 1.9 MB
Cite
Cite this package
Run in R for the authors' preferred citation:
citation("SEQTaRget")This package has no citation file, so citation() returns this entry built from DESCRIPTION.
The repository also keeps a CITATION.cff.
Cite the R Observatory
For a number measured here: a download total, a coverage figure, an archival date.
From data release v2026-10-24, which the citation names so these numbers can be found later. More on citing and the projects behind them.