Description Usage Arguments Value Examples
Predict the node id of MrSGUIDE regression tree
1 | predictTree(mrsobj, dataframe, type = "node")
|
mrsobj |
MrSGUIDE object |
dataframe |
data used for prediction |
type |
node id |
A data frame of each object node id and outcome
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | library(MrSGUIDE)
set.seed(1234)
N = 200
np = 3
numX <- matrix(rnorm(N * np), N, np) ## numerical features
gender <- sample(c('Male', 'Female'), N, replace = TRUE)
country <- sample(c('US', 'UK', 'China', 'Japan'), N, replace = TRUE)
z <- sample(c(0, 1), N, replace = TRUE) # Binary treatment assignment
y1 <- numX[, 1] + 1 * z * (gender == 'Female') + rnorm(N)
y2 <- numX[, 2] + 2 * z * (gender == 'Female') + rnorm(N)
train <- data.frame(numX, gender, country, z, y1, y2)
role <- c(rep('n', 3), 'c', 'c', 'r', 'd', 'd')
mrsobj <- MrSFit(dataframe = train, role = role)
newX = train[1:10,]
predictTree(mrsobj, newX, type='outcome')
predictTree(mrsobj, newX, type='node')
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.