Learn R Programming

DTRlearn (version 1.3)

predict.qlearn: Predict optimal treatment by Qlearning

Description

This function predicts optimal treatments for a given Q-learning model of class 'qlearn'.

Usage


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

Arguments

object

a model with class 'qlearn'

x

a matrix of feature variables,has p columns that is p dimensions of feature variables

...

further arguments passed to or from other methods.

Value

a vector of optimal treatments, each entry is for a row in x, the matrix of new feature variables.

See Also

Qlearning_Single

Examples

Run this code
# NOT RUN {
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