Description Usage Arguments Value See Also Examples
Estimate the causal survival curve for a particular stochastic, dynamic or static intervention on the treatment/exposure and monitoring process. Implements the IPW (Inverse Probability-Weighted or Horvitz-Thompson) estimator of the discrete survival hazard function which is mapped into survival function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 | stremr(
data,
ID = "Subj_ID",
t_name = "time_period",
covars,
CENS = "C",
TRT = "A",
MONITOR = "N",
OUTCOME = "Y",
gform_CENS,
gform_TRT,
gform_MONITOR,
stratify_CENS = NULL,
stratify_TRT = NULL,
stratify_MONITOR = NULL,
intervened_TRT = NULL,
noCENScat = 0L,
remove_extra_rows = TRUE,
nfolds = NULL,
models_CENS = sl3::Lrnr_glm_fast$new(family = quasibinomial()),
models_TRT = sl3::Lrnr_glm_fast$new(family = quasibinomial()),
models_MONITOR = sl3::Lrnr_glm_fast$new(family = quasibinomial()),
fit_method_g = "none",
models_Q = sl3::Lrnr_glm_fast$new(family = quasibinomial()),
fit_method_Q = "none",
Qforms = NULL,
tvals = NULL,
stratifyQ_by_rule = TRUE,
trunc_IPW_MSM = Inf,
trunc_IPW_TMLE = Inf,
seed = NULL,
MSMGLMpkg = c("speedglm", "h2o"),
tbreaks = NULL,
start_h2o_cluster = TRUE,
nthreads = 2,
verbose = getOption("stremr.verbose")
)
|
data |
Input data in long format. Can be a |
ID |
Unique subject identifier column name in |
t_name |
The name of the time/period variable in |
covars |
Vector of names with time varying and baseline covariates in |
CENS |
Column name of the censoring variable(s) in |
TRT |
A column name in |
MONITOR |
A column name in |
OUTCOME |
A column name in |
gform_CENS |
Regression formula(s) for estimating the propensity score for the censoring mechanism: P(C(t) | W). See Details. |
gform_TRT |
Regression formula(s) for propensity score for the exposure/treatment(s): P(A(t) | W). See Details. |
gform_MONITOR |
Regression formula(s) for estimating the propensity score for the MONITORing process: P(N(t) | W). See Details.
(the observed exposure mechanism), When omitted the regression is defined by |
stratify_CENS |
A named list with one item per variable in |
stratify_TRT |
A named list with one item per variable in |
stratify_MONITOR |
A named list with one item per variable in |
intervened_TRT |
Column name in |
noCENScat |
Same as in |
remove_extra_rows |
Same as in |
nfolds |
Number of folds for cross-validation (leave as |
models_CENS |
Same as in |
models_TRT |
Same as in |
models_MONITOR |
Same as in |
fit_method_g |
Same as |
models_Q |
Same as |
fit_method_Q |
Same as |
Qforms |
Same as in |
tvals |
Same as in |
stratifyQ_by_rule |
Same as in |
trunc_IPW_MSM |
Weight truncation for IPW-based functions. |
trunc_IPW_TMLE |
Weight trunction for TMLE. |
seed |
Random generator seed. |
MSMGLMpkg |
Package to use for MSM GLM fits (see |
tbreaks |
Same as in |
start_h2o_cluster |
Start h2o cluster? |
nthreads |
Number of threads (CPUs) to use for h2o cluster? |
verbose |
Set to |
...
stremr-package
for the general overview of the package,
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | #-------------------------------------------------------------------
# EXAMPLE WITH CATEGORICAL CENSORING (3 levels)
#-------------------------------------------------------------------
require("data.table")
require("magrittr")
data(OdataCatCENS)
OdataDT <- as.data.table(OdataCatCENS, key=c("ID", "t"))
# Indicator that the person has never been treated in the past:
OdataDT[, "barTIm1eq0" := as.integer(c(0, cumsum(TI)[-.N]) %in% 0), by = ID]
# Define lagged N, first value is always 1 (always monitored at the first time point):
OdataDT[, ("N.tminus1") := shift(get("N"), n = 1L, type = "lag", fill = 1L), by = ID]
#-------------------------------------------------------------------
# Regressions for modeling the exposure (TRT)
#-------------------------------------------------------------------
gform_TRT <- "TI ~ CVD + highA1c + N.tminus1"
# Fit a separate model for TRT (stratify) for each of the following subsets:
stratify_TRT <- list(
TI=c(
# MODEL TI AT t=0
"t == 0L",
# MODEL TRT INITATION WHEN MONITORED
"(t > 0L) & (N.tminus1 == 1L) & (barTIm1eq0 == 1L)",
# MODEL TRT INITATION WHEN NOT MONITORED
"(t > 0L) & (N.tminus1 == 0L) & (barTIm1eq0 == 1L)",
# MODEL TRT CONTINUATION (BOTH MONITORED AND NOT MONITORED)
"(t > 0L) & (barTIm1eq0 == 1L)"
))
#-------------------------------------------------------------------
# Regressions for modeling the categorical censoring (CENS)
#-------------------------------------------------------------------
gform_CENS <- c("CatC ~ highA1c")
# stratify by time-points (separate model for all t<16 and t=16)
stratify_CENS <- list(CatC=c("t < 16", "t == 16"))
#-------------------------------------------------------------------
# Regressions for modeling the monitoring regimen (MONITOR)
#-------------------------------------------------------------------
# Intercept only model, pooling across all time points t
gform_MONITOR <- "N ~ 1"
#-------------------------------------------------------------------
# Define the counterfactual monitoring regimen of interest
#-------------------------------------------------------------------
# probability of being monitored at each t is 0.1
OdataDT[, "gstar.N" := 0.1]
# Define two dynamic rules: dlow & dhigh
OdataDT <- defineIntervedTRT(OdataDT, theta = c(0,1), ID = "ID", t = "t", I = "highA1c",
CENS = "C", TRT = "TI", MONITOR = "N", tsinceNis1 = "lastNat1",
new.TRT.names = c("dlow", "dhigh"), return.allcolumns = TRUE)
# # Estimate IPW-based hazard and survival (KM) for a rule "dhigh":
# IPW_KM_res <- stremr(OdataDT, intervened_TRT = "dhigh", intervened_MONITOR = "gstar.N",
# ID = "ID", t = "t", covars = c("highA1c", "lastNat1"),
# CENS = "CatC", gform_CENS = gform_CENS, stratify_CENS = stratify_CENS,
# TRT = "TI", gform_TRT = gform_TRT, stratify_TRT = stratify_TRT,
# MONITOR = "N", gform_MONITOR = gform_MONITOR, OUTCOME = "Y.tplus1")
# # Survival estimates by time:
# IPW_KM_res$estimates
# # Input data:
# IPW_KM_res$dataDT
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.