Learn R Programming

DTRlearn (version 1.0)

predict.linearcl: Predict

Description

predict the best treatment for model with class 'linearcl' produced by wsvm with linear kernel

Usage

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

Arguments

object
model of class 'linearcl'
x
a matrix of feature varaibles, n by p
...
further arguments passed to or from other methods.

Value

  • a vector of optimal treatment for each row of x

See Also

wsvm

Examples

Run this code
n=200
A=2*rbinom(n,1,0.5)-1
p=20
mu=numeric(p)
Sigma=diag(p)
#feature variable is multi variate normal
X=mvrnorm(n,mu,Sigma)
#the outcome is generated where the true optimal treatment
#is sign of the interaction term(of treatment and feature)
R=X[,1:3]%*%c(1,1,-2)+X[,3:5]%*%c(1,1,-2)*A+rnorm(n)

# linear SVM
model1=wsvm(X,A,R)
m=100
Xtest=mvrnorm(m,mu,Sigma)
predict(model1,Xtest)

Run the code above in your browser using DataLab