| feasible | R Documentation |
Estimate a family of feasible intervention strategies for a continuous treatment (and optionally time-varying covariates). The method returns, for each intervention strategy, the corresponding “feasible” intervention values and a summary of overlap and positivity-violation diagnostics.
feasible(
X, Anodes = NULL, Ynodes = NULL, Lnodes = NULL, Cnodes = NULL,
abar = NULL,
alpha = 0.95, grid.size = 0.5, tol = 1e-2,
left.boundary = NULL, right.boundary = NULL,
screen = FALSE, survival = FALSE,
d.method = c("hazardbinning", "binning", "parametric", "hal_density"),
verbose = TRUE, ...
)
X |
A data frame containing all nodes in temporal order. Columns must include
the treatment, outcome, covariate and censoring nodes specified in
|
Anodes |
Character vector giving the column names in |
Ynodes |
Character vector giving the column names in |
Lnodes |
Optional character vector of confounder nodes. May be |
Cnodes |
Optional character vector of censoring (or competing event) nodes.
May be |
abar |
Numeric vector or matrix specifying the target interventions.
The argument must be numeric; |
alpha |
Numeric scalar in |
grid.size |
Positive numeric scalar giving the spacing of the grid used to
approximate the treatment density. If |
tol |
Non-negative numeric tolerance used when combining |
left.boundary |
Optional numeric scalar setting the left boundary of the
grid used to approximate the treatment density. If |
right.boundary |
Optional numeric scalar setting the right boundary of the
density grid. If |
screen |
Logical; if |
survival |
Logical; indicates whether the outcome nodes correspond to a
survival-type structure. Passed to the internal model-building function.
Default is |
d.method |
Character string specifying the density-estimation method used
to estimate the conditional treatment density. Must be one of
|
verbose |
Logical; if |
... |
Additional arguments passed to the underlying density-estimation
function determined by |
The main steps of the algorithm are:
Model specification:
Treatment models for each time point are constructed via helper routines from
CICI. If screen = TRUE, a screening step updates the treatment
formulas before density estimation (only recommended to address computational constraints).
Grid construction:
A grid of treatment values, query_abar, is formed by combining:
observed treatment values in X[, Anodes],
the target values in abar, and
a regular grid from left.boundary to right.boundary
with spacing grid.size (when grid.size is not NULL).
If grid.size = NULL, the grid is restricted to the unique values in
abar (only allowed when abar is a vector).
Density estimation:
For each time point, the conditional treatment density is evaluated on the
grid for each observation using the specified d.method. The resulting
matrices are normalised so that each row integrates to one over the grid
(accounting for bin width).
Feasibility threshold:
For each observation and time point, a density threshold f_\alpha is
computed such that the cumulative mass below the sorted densities first
exceeds 1 - alpha. Cells with density below f_\alpha are flagged
as “infeasible”.
Feasible mapping:
For each grid cell with density below f_\alpha, the algorithm finds the
closest grid cell with density at or above f_\alpha (in terms of grid
index) and maps its value to that cell. This defines a “feasible”
intervention that avoids low-density regions.
Summary:
For each time point t and each intervention strategy (row of
abar), the method collects:
the mean feasible value across individuals (column Feasible),
the proportion of cells below the density threshold (column
Low, interpreted as %infeasible in the associated
S3 methods),
the corresponding target value Abar at time t, and
the strategy index Strategy.
These are combined into a data frame stored as the "summary" attribute
of the returned object.
Plotting and printing methods are available for visual and tabular diagnostics;
see plot.feasible, print.feasible, and
summary.feasible.
An object of class "feasible" with the following components:
feasible: a list of length equal to the number of strategies
(rows of abar). Each element is a matrix with one column per
time point, containing the feasible intervention values for that
strategy and time point across observations.
low_matrix: a list of length equal to the number of time points.
Each element is a logical matrix indicating, on the internal grid, which
cells were marked as below the density threshold.
The object additionally has a "summary" attribute, a data frame with at
least the columns time, Strategy, Abar, Feasible,
and Low, which is accessed and formatted by summary.feasible
and print.feasible.
plot.feasible, print.feasible,
summary.feasible
data(EFV)
Lnodes <- c("adherence.1","weight.1",
"adherence.2","weight.2",
"adherence.3","weight.3",
"adherence.4","weight.4")
Ynodes <- c("VL.0","VL.1","VL.2","VL.3","VL.4")
Anodes <- c("efv.0","efv.1","efv.2","efv.3","efv.4")
## ------------------------------------------------------------------
## Example 1: Hazard binning with default grid
## Static grid of targets (vector abar) over the full support of efv.*
## ------------------------------------------------------------------
abar_static <- seq(0, 10, by = 1)
m_hazard <- feasible(
X = EFV,
Anodes = Anodes,
Lnodes = Lnodes,
Ynodes = Ynodes,
d.method = "hazardbinning", # long computation, but appropriate
abar = abar_static,
grid.size = 0.5,
left.boundary = 0,
right.boundary = 10
)
## Individual-level feasible values (one matrix per strategy):
## rows = individuals, columns = time points
feasible_matrix <- m_hazard$feasible # pass on to gformula/sgf
lapply(feasible_matrix, head)
## Inspect feasability of strategies
m_hazard # see also ?print.feasible
summary(m_hazard) # see also ?summary.feasible
## ------------------------------------------------------------------
## Example 2: Parametric density, using abar as the grid
## Here grid.size = NULL, so only the target values are used as grid
## ------------------------------------------------------------------
abar_param <- seq(0, 10, by = 2)
m_param <- feasible(
X = EFV,
Anodes = Anodes,
Lnodes = Lnodes,
Ynodes = Ynodes,
# fast, but only useful for reasonably symmetric distributions
d.method = "parametric",
abar = abar_param,
grid.size = NULL,
left.boundary = 0,
right.boundary = 10
)
## Inspect feasability of strategies
m_param # see also ?print.feasible
summary(m_param) # see also ?summary.feasible
## ------------------------------------------------------------------
## Example 3: Matrix abar with non-constant strategies over time
## Each row is a strategy, each column corresponds to efv.0, ..., efv.4
## ------------------------------------------------------------------
abar_matrix <- rbind(
c(0, 2, 4, 6, 8), # strategy 1
c(9, 6, 2, 1, 0), # strategy 2
c(1, 3, 5, 7, 9) # strategy 3
)
m_matrix <- feasible(
X = EFV,
Anodes = Anodes,
Lnodes = Lnodes,
Ynodes = Ynodes,
d.method = "parametric",
abar = abar_matrix,
grid.size = 1,
left.boundary = 0,
right.boundary = 10
)
## Inspect feasability of strategies
m_matrix # see also ?print.feasible
summary(m_matrix) # see also ?summary.feasible
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.