# NOT RUN {
## ------------------------------------------------------------
## survival/competing risk
## ------------------------------------------------------------
## survival
data(veteran, package = "randomForestSRC")
v.obj <- rfsrc(Surv(time,status)~., veteran, nsplit = 10, ntree = 100)
partial.obj <- partial(v.obj,
partial.type = "rel.freq",
partial.xvar = "age",
partial.values = v.obj$xvar[, "age"],
partial.time = v.obj$time.interest)
## competing risks
data(follic, package = "randomForestSRC")
follic.obj <- rfsrc(Surv(time, status) ~ ., follic, nsplit = 3, ntree = 100)
partial.obj <- partial(follic.obj,
partial.type = "cif",
partial.xvar = "age",
partial.values = follic.obj$xvar[, "age"],
partial.time = follic.obj$time.interest)
## regression
airq.obj <- rfsrc(Ozone ~ ., data = airquality)
partial.obj <- partial(airq.obj,
partial.xvar = "Wind",
partial.values = airq.obj$xvar[, "Wind"],
oob = FALSE)
## classification
iris.obj <- rfsrc(Species ~., data = iris)
partial.obj <- partial(iris.obj,
partial.xvar = "Sepal.Length",
partial.values = iris.obj$xvar[, "Sepal.Length"])
## multivariate mixed outcomes
mtcars2 <- mtcars
mtcars2$carb <- factor(mtcars2$carb)
mtcars2$cyl <- factor(mtcars2$cyl)
mtcars.mix <- rfsrc(Multivar(carb, mpg, cyl) ~ ., data = mtcars2)
partial.obj <- partial(mtcars.mix,
partial.xvar = "disp",
partial.values = mtcars.mix$xvar[, "disp"])
## second order variable specification
mtcars.obj <- rfsrc(mpg ~., data = mtcars)
partial.obj <- partial(mtcars.obj,
partial.xvar = "cyl",
partial.values = c(4, 8),
partial.xvar2 = c("gear", "disp", "carb"),
partial.values2 = c(4, 200, 3))
# }
Run the code above in your browser using DataLab