View source: R/main_algorithm.R
| main_algorithm | R Documentation |
Executes the full estimation pipeline for learning an optimal treatment policy under constraints.
This function performs the complete procedure implemented in the PLUCR framework.
It begins by validating and preprocessing the input data, followed by estimating nuisance parameters using the SuperLearner ensemble library.
Subsequently, it estimates the optimal treatment policy via the Frank-Wolfe optimization algorithm.
The procedure includes an inner grid search over candidate values of lambda and beta to identify the policy
that maximizes the expected primary outcome (policy value) while satisfying a constraint on the expected rate of adverse events.
main_algorithm(
X,
A,
Y,
Xi,
Lambdas = seq(1, 8, by = 1),
alpha = 0.1,
precision = 0.05,
B = c(0, 0.05, 0.1, 0.25, 0.5),
centered = FALSE,
Jfold = 3L,
V = 2L,
SL.library = c("SL.mean", "SL.glm", "SL.ranger", "SL.grf"),
tol = 0.025,
max_iter = 5,
root.path
)
X |
A matrix of covariates of size n x d (input data in |
A |
A binary vector of size n indicating treatment assignment (0 or 1). |
Y |
A numeric vector or matrix of length n representing primary outcomes (in |
Xi |
A numeric vector or matrix of length n indicating adverse events (0 or 1). |
Lambdas |
A sequence of non-negative numeric scalars controlling the penalty for violating the constraint (seq(1,8,by=1) by default). |
alpha |
A numeric scalar representing the constraint tolerance (in |
precision |
A numeric scalar defining the desired convergence precision (0.05 by default). The number of Frank-Wolfe iterations (K) is inversely proportional to this value, calculated as 1/precision. |
B |
A vector of non-negative scalars controlling the sharpness of the treatment probability function (c(0, 0.05, 0.1, 0.25, 0.5) by default). |
centered |
A logical value indicating whether to apply centering in |
Jfold |
Number of folds for the main algorithm, needs to be set to 3L. |
V |
Number of folds inside the SuperLearner (2L by default). |
SL.library |
Vector of libraries for training Super Learner (c("SL.mean","SL.glm","SL.ranger","SL.grf") by default). |
tol |
A numeric scalar used as an early stopping criterion based on the RMSE between consecutive solutions (0.025 by default). |
max_iter |
A numeric scalar specifying the maximum number of iterations (5 by default). |
root.path |
Path to the folder where all results are to be saved. |
A list of matrices (theta_0 and theta_final), or theta_0 alone.
These matrices are used to construct the optimal treatment rule in two steps.
First, build psi using the make_psi function and evaluate it at X (i.e., psi(X)).
Then, obtain the optimal treatment rule by applying sigma_beta to the selected beta attribute.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.