predict.ccif: Predictions from a Fitted Causal Conditional Inference Forest...

Description Usage Arguments Details Value Author(s) References Examples

View source: R/predict.R

Description

prediction of new data using causal conditional inference forest.

Usage

1
2
## S3 method for class 'ccif'
predict(object, newdata, n.trees = object$ntree, predict.all = FALSE, ...)

Arguments

object

an object of class ccif, as that created by the function ccif.

newdata

a data frame containing the values at which predictions are required.

n.trees

number of trees used in the prediction; The default is object$ntree.

predict.all

should the predictions of all trees be kept?

...

not used.

Details

At the moment, all predictors passed for fitting the uplift model must also be present in newdata, even if they are not used as split variables by any of the trees in the forest.

Value

If predict.all = FALSE, a matrix of predictions containing the conditional class probabilities: pr.y1_ct1 represents Prob(y=1|treated, x) and pr.y1_ct0 represents Prob(y=1|control, x). This is computed as the average of the individual predictions over all trees.

If predict.all = TRUE, the returned object is a list with two components: pred.avg is the prediction (as described above) and individual is a list of matrices containing the individual predictions from each tree.

Author(s)

Leo Guelman <leo.guelman@gmail.com>

References

Guelman, L., Guillen, M., and Perez-Marin A.M. (2013). Optimal personalized treatment rules for marketing interventions: A review of methods, a new proposal, and an insurance case study. Submitted.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
library(uplift)

### Simulate train data

set.seed(12345)
dd <- sim_pte(n = 100, p = 6, rho = 0, sigma =  sqrt(2), beta.den = 4)
dd$treat <- ifelse(dd$treat == 1, 1, 0) 

### Fit model

form <- as.formula(paste('y ~', 'trt(treat) +', paste('X', 1:6, sep = '', collapse = "+"))) 

fit1 <- ccif(formula = form,
             data = dd, 
             ntree = 50, 
             split_method = "Int",
             pvalue = 0.05,
             verbose = TRUE)

### Predict on new data

dd_new <- sim_pte(n = 200, p = 20, rho = 0, sigma =  sqrt(2), beta.den = 4)

pred <- predict(fit1, dd_new)

Example output

Loading required package: RItools
Loading required package: SparseM

Attaching package: 'SparseM'

The following object is masked from 'package:base':

    backsolve

Loading required package: MASS
Loading required package: coin
Loading required package: survival
Loading required package: tables
Loading required package: Hmisc
Loading required package: lattice
Loading required package: Formula
Loading required package: ggplot2

Attaching package: 'Hmisc'

The following objects are masked from 'package:base':

    format.pval, units

Loading required package: penalized
Welcome to penalized. For extended examples, see vignette("penalized").
uplift: status messages enabled; set "verbose" to false to disable
ccif: starting. Thu Feb 28 07:45:08 2019 
10 out of 50 trees so far...
20 out of 50 trees so far...
30 out of 50 trees so far...
40 out of 50 trees so far...

uplift documentation built on May 2, 2019, 9:32 a.m.