# listdtr: Estimation of List-based Optimal Dynamic Treatment Regime In listdtr: List-Based Rules for Dynamic Treatment Regimes

## Description

Estimate the optimal dynamic treatment regime / individualized treatment rule, in the form of decision list, namely, a sequence of if-then clauses.

## Usage

 ```1 2 3``` ```listdtr(y, a, x, stage.x, seed = NULL, kfolds = 5L, fold = NULL, maxlen = 10L, zeta.choices = NULL, eta.choices = NULL) ```

## Arguments

 `y` a matrix of immediate outcomes, of size `n.obs` by `n.stage`, where `n.obs` is the number of observations and `n.stage` is the number of stages. Assume larger outcomes are more favorable. `a` a matrix of treatments/interventions actually received at each stage, of size `n.obs` by `n.stage`. `x` a matrix of features (such as demographics, biomarkers, confounders), of size `n.obs` by `n.feature`, where `n.feature` is the number of features measured at any of the stages. `stage.x` a vector of length `n.feature`, with values in 1, ..., `n.stage` that gives the stage at which each feature is measured. `seed` seed for random number generator to obtain `fold`. Omitted if `fold` is not null. `kfolds` number of folds to perform cross validation. `fold` a vector of length `n.obs` that specifies fold membership for each observation. `maxlen` maximum length of the decision list in each stage. Should be a scalar. `zeta.choices` Choices for the tuning parameter zeta. Larger value of zeta tends to construct a condition that covers more observations in each if-then clause. Should be null or a numeric vector. `eta.choices` Choices for the tuning parameter eta. Larger value of eta tends to construct a condition that uses less features in each if-then clause. Should be null or a numeric vector.

## Details

The algorithm is quite complicated. See the reference if interested.

## Value

An object of class `listdtr`.

## References

`predict.listdtr`, `print.listdtr`, `plot.listdtr`, `build.rule.cv`
 ``` 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``` ``` # an example for one-stage study x <- matrix(rnorm(500), 100, 5) stage.x <- rep(1, 5) a <- rbinom(100, 1, 0.5) y <- a * x[, 1] + rnorm(100, 0, 0.1) dtr <- listdtr(y, a, x, stage.x) dtr # display the regime in words plot(dtr) # display the regime in diagrams yrec <- predict(dtr, x, 1) yopt <- ifelse(x[, 1] > 0, 1, 0) table(yrec, yopt) # discrepancy between recommended and optimal # an example for two-stage study x <- matrix(rnorm(500), 100, 5) stage.x <- c(1, 1, 1, 2, 2) a1 <- rbinom(100, 1, 0.5) a2 <- rbinom(100, 1, 0.5) y1 <- rep(0, 100) y2 <- 9 * a1 * sin(x[, 1] * pi / 8) - 2 * a2 * x[, 4] + rnorm(100) dtr <- listdtr(cbind(y1, y2), cbind(a1, a2), x, stage.x) dtr # display the regime in words plot(dtr) # display the regime in diagrams yrec <- predict(dtr, x, 1) yopt <- ifelse(x[, 1] > 0, 1, 0) table(yrec, yopt) # discrepancy between recommended and optimal ```