predict.ql {DTRlearn2} | R Documentation |
Predict from a Fitted "ql" Object
Description
This function serves two purposes from a fitted "ql" object. It can recommend treatments for a new independent sample with partial or full subject features observed up to a certain stage. If subject features, treatment assignments and outcomes are fully observed in the new sample, this function can also evaluate the fitted DTR on this new sample, returning the empirical value function and benefit function.
Usage
## S3 method for class 'ql'
predict(object, H, AA=NULL, RR=NULL, K, pi=NULL, Qopt=FALSE, Qfit=FALSE, ...)
Arguments
object |
fitted "ql" object |
H |
subject history information before treatment at the |
AA |
observed treatment assignments at the |
RR |
observed outcomes at the |
K |
number of stages of |
pi |
treatment assignment probabilities of the observed treatments at the K stages for all subjects in the new sample. It is a vector if |
Qopt |
whether to output the predicted optimal Q-function. The default is |
Qfit |
whether to output the estimated Q-function under the observed treatments. The default is |
... |
further arguments passed to or from other methods. |
Value
treatment |
recommennded optimal treatments at the K stages for each subject in the new sample. It is a list of K vectors. If no tailoring variables are learned in the "ql" object, treatments will be assigned randomly with equal probability. |
valuefun |
overall empirical value function under the fitted DTR evaluated on the new sample. It is returned only when |
benefit |
overall empirical benefit function under the estimated DTR evaluated on the new sample. It is returned only when |
pi |
treatment assignment probabilities of the assigned treatments at the K stages for each subject in the new sample. If |
Q |
the predicted optimal Q-function if |
fitted |
the estimated Q-function under the observed treatment if |
Author(s)
Yuan Chen, Ying Liu, Donglin Zeng, Yuanjia Wang
Maintainer: Yuan Chen <yc3281@columbia.edu><irene.yuan.chen@gmail.com>
See Also
ql
, sim_Kstage
, owl
Examples
# simulate 2-stage training and test sets
n_train = 100
n_test = 500
n_cluster = 10
pinfo = 10
pnoise = 20
train = sim_Kstage(n_train, n_cluster, pinfo, pnoise, K=2)
H1_train = scale(train$X)
H2_train = scale(cbind(H1_train, train$A[[1]], H1_train * train$A[[1]]))
pi_train = list(rep(0.5, n_train), rep(0.5, n_train))
test = sim_Kstage(n_test, n_cluster, pinfo, pnoise, train$centroids, K=2)
H1_test = scale(test$X)
H2_test = scale(cbind(H1_test, test$A[[1]], H1_test * train$A[[1]]))
pi_test = list(rep(0.5, n_test), rep(0.5, n_test))
# estimate DTR with ql on the training sample
ql_train = ql(H=list(H1_train, H2_train), AA=train$A, RR=train$R, K=2, pi=pi_train, m=3)
# evaluate the DTR when full information are observed on the new sample
ql_test = predict(ql_train, H=list(H1_test, H2_test), AA=test$A, RR=test$R, K=2)
ql_test$treatment
ql_test$valuefun
ql_test$pi
# recommned the first-stage treatments only
ql_test2 = predict(ql_train, H=H1_test, K=1)
ql_test2$treatment