The goal of SEQ is to implement sequentially nested trial emulation for the analysis of observational databases. The SEQ software accommodates time-varying treatments and confounders, as well as binary and failure time outcomes. SEQ 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.
You can install the development version of SEQ from GitHub with:
install.packages("devtools")
::install_github("CausalInference/SEQuential", subdir = "SEQTaRget") devtools
SEQuential
uses R’s S4 object class system to handle
function input/output. From the user side, this amounts to calling a
helpful constructor SEQopts
and then feeding that into
SEQuential
. SEQestimate
can also take the
provided options and return a (very rough) estimated time for
analysis.
library(SEQTaRget)
<- SEQdata
data
<- SEQuential(data, id.col = "ID", time.col = "time",
model eligible.col = "eligible", treatment.col = "tx_init",
outcome.col = "outcome",
time_varying.cols = c("N", "L", "P"),
fixed.cols = "sex",
method = "ITT",
options = SEQopts(km.curves = TRUE))
outcome(model) # Returns a list of all outcome models as S3 fastglm objects over the course of bootstrapping
<- diagnostics(model) # Returns a list of diagnostic tables
diagnostics $outcome.unique[[1]] # Returns a table of unique outcomes
diagnostics$outcome.nonunique[[1]] # Returns a table of nonunique outcomes
diagnostics
# Plotting
km_curve(model)[[1]] # Returns the Survival curve
km_data(model)[[1]] # Returns a dataframe of survival data in long-format for other analysis/plotting
This package places several assumptions onto the input data and unexpected results and errors may arise if these are not followed-
time.col
begins at 0 per unique
id.col
entries, we also assume that the column contains
only integers and continues by 1 for every time step. e.g. (0, 1, 2, 3,
…) is allowed and (0, 1, 2, 2.5, …) or (0, 1, 2, 4, 5, …) are not.
time.col
entries may be out of order as a sort
is enforced at the beginning of the function, e.g. (0, 2, 1, 4, 3, …) is
valid because it begins at 0 and is continuously increasing by
increments of 1, even though it is not ordered.eligible
and colnumn names provided to
excused.cols
are once one only one (with respect to
time.col
) flag variablesThe primary function, SEQuential
, returns an S4 object
of class SEQoutput
with slots:
These can be handily and easily printed to the terminal with by
calling the object as model
(if continuing the example
above). While this this the shape of the output object, not all slots
will always be filled, e.g. if a user providers
hazard = TRUE
, then the survival curves, data, and
associated risks will return NA
.
Further information on utilizing this package or developing it further is available with the SEQuential Pages as a part of this repository. If you are unable to find solutions or answers there, please feel free to open a discussion.
Community members are welcome to contribute to this package through several different avenues-