predict.ITR: Treatment Prediction for rcDT and rcRF Models

Description Usage Arguments Value Examples

View source: R/predict.ITR.R

Description

Used to make treatment prediction for a rcDT and rcRF models. If the input is rcRF (forest), then the proportion of trees voting for treatment ('trt=1') is returned. If the input is rcDT (single tree), then the function returns the vote (0 / 1) for the model.

Usage

1
2
## S3 method for class 'ITR'
predict(fit, new.data, split.var, ctgs = NULL)

Arguments

fit

tree or forest object from 'grow.ITR' or 'Build.RF.ITR'.

new.data

data for which predictions are desired

split.var

splitting variables from the model fit

ctgs

columns of categorical variables.

Value

A summary list of the following elements:

SummaryTreat

proportion of trees voting for treatment (trt=1). If input is rcDT (single tree) then SummaryTreat is a single number. If input is rcRF (forest) then SummaryTreat is a vector equal to the length of the number of trees.

trt.pred

vector of treatment assignments 0, 1 based on the tree vote (single tree) or majority of tree votes (forest). This vector has length equal to the number of rows in 'new.data'.

n.trees

number of tree in 'fit'

tree.votes

matrix of votes for each tree for each subject in 'new.data'. Rows correspond to trees in 'fit' and columns correspond to subjects in 'new.dat'.

data

input data frame 'new.data'

NA.trees

number of trees returning no votes. In a forest, this is the number of null trees.

Examples

1
2
3
4
5
6
7
dat <- generateData()
# Generates rcDT using simualated data with splitting variables located in columns 1-10.
tree <- grow.ITR(data = dat, split.var = 1:10, 
                 risk.control = TRUE, risk.threshold = 2.75, 
                 lambda = 1)
# Predict treatment assignments for 1000 observations in `dat`
preds <- predict.ITR(fit = tree, new.data = dat, split.var = 1:10)

kdoub5ha/mvITR documentation built on April 7, 2020, 3:59 a.m.