Learn R Programming

DTRlearn (version 1.0)

predict.qlearn: Predict optimal treatment by Qlearning

Description

This is function to predict optimal treatment for given Q-learning model of class qlearn and feature variable x

Usage

## S3 method for class 'qlearn'
## S3 method for class 'qlearn':
predict(object, x,...)

Arguments

object
with class 'qlearn'
x
a matrix of feature varaibles,has p colunms, p dimensions of feature variables
...
further arguments passed to or from other methods.

Value

  • a vector of optimal treatment for each row of x

See Also

Qlearning_Single

Examples

Run this code
n=200
A=2*rbinom(n,1,0.5)-1
p=10
mu=numeric(p)
Sigma=diag(p)
X=mvrnorm(n,mu,Sigma)
R=X[,1:3]%*%c(1,1,-2)+X[,3:5]%*%c(1,1,-2)*A+rnorm(n)

model1=Qlearning_Single(X,A,R)
m=100
Xtest=mvrnorm(m,mu,Sigma)
predict(model1,Xtest)

Run the code above in your browser using DataLab