Description Usage Arguments Value Examples
Returns treatment predictions for a rcDT and rcRF models given a new data set. 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.
1 2 |
fit |
tree or forest object from 'rcDT' or 'rcRF'. |
new.data |
data.frame of new observations |
split.var |
numeric vector indicating columns of covariates |
ctgs |
numeric vector of columns of categorical covariates. |
A list of prediction summaries
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. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | # Generate simulated data
set.seed(123)
dat <- generateData()
# Generates rcDT using simualated data with splitting variables located in columns 1-10.
rcDT.fit <- rcDT(data = dat,
split.var = 1:10,
risk.threshold = 2.75,
lambda = 1)
# Predict treatment assignments for 1000 observations in `dat` using the rcDT model
preds.rcDT <- predict.ITR(fit = rcDT.fit, new.data = dat, split.var = 1:10)
# Generates rcRF using simualated data with splitting variables located in columns 1-10.
set.seed(2)
rcRF.fit <- rcRF(data = dat,
split.var = 1:10,
ntree = 200,
risk.threshold = 2.75,
lambda = 1)
# Predict treatment assignments for 1000 observations in `dat` using the rcRF model
preds.rcRF <- predict.ITR(fit = rcRF.fit, new.data = dat, split.var = 1:10)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.