predict.linearcl: Predict

Description Usage Arguments Value Author(s) See Also Examples

View source: R/predict.R

Description

This function predicts the optimal treatments with model of class 'linearcl', which is estimated by wsvm with 'linear' kernel.

Usage

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

Arguments

object

model of class 'linearcl'

x

a matrix of feature variables, n by p

...

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.

Author(s)

Ying Liu

See Also

wsvm

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
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)

DTRlearn documentation built on April 6, 2018, 1:04 a.m.