Learn R Programming

randomForestSRC (version 2.4.1)

partial.rfsrc: Acquire Partial Effect of a Variable

Description

Acquire the partial effect of a variable on the ensembles.

Usage

partial.rfsrc(object, outcome.target = NULL, partial.type = NULL, partial.xvar = NULL, partial.values = NULL, partial.time = NULL, oob = TRUE, seed = NULL, do.trace = FALSE, ...)

Arguments

object
An object of class (rfsrc, grow).
outcome.target
Character value for multivariate families specifying the target outcome to be used. The default is to use the first coordinate.
partial.type
Character value of the type of predicted value. See details below.
partial.xvar
Character value specifying the x-variable to be used.
partial.values
Values for x-variable on which the partial values are to be calculated.
partial.time
For survival families, the time at which the predicted survival value is evaluated at (depends on partial.type).
oob
OOB (TRUE) or in-bag (FALSE) predicted values.
seed
Negative integer specifying seed for the random number generator.
do.trace
Number of seconds between updates to the user on approximate time to completion.
...
Further arguments passed to or from other methods.

Details

  1. For regression, the predicted response is used.
  2. For survival, the choices are:
    • Relative frequency of mortality (rel.freq) or mortality (mort) is of dim [n] x [length(partial.values)].
    • The cumulative hazard function (chf) is of dim [n] x [length(partial.time)] x [length(partial.values)].
    • The survival function (surv) is of dim [n] x [length(partial.time)] x [length(partial.values)].

  • For competing risks, the choices are:
    • The expected number of life years lost (years.lost) is of dim [n] x [length(event.info$event.type)] x [length(partial.values)].
    • The cumulative incidence function (cif) is of dim [n] x [length(partial.time)] x [length(event.info$event.type)] x [length(partial.values)].
    • The cumulative hazard function (chf) is of dim [n] x [length(partial.time)] x [length(event.info$event.type)] x [length(partial.values)].
  • For regression, it is of dim [n] x [length(partial.values)].
  • For classification, it is of dim [n] x [1 + yvar.nlevels[.]] x [length(partial.values)].
  • References

    Ishwaran H., Kogalur U.B. (2007). Random survival forests for R, Rnews, 7(2):25-31. Ishwaran H., Kogalur U.B., Blackstone E.H. and Lauer M.S. (2008). Random survival forests, Ann. App. Statist., 2:841-860. Ishwaran H., Gerds T.A., Kogalur U.B., Moore R.D., Gange S.J. and Lau B.M. (2014). Random survival forests for competing risks. Biostatistics, 15(4):757-773.

    See Also

    plot.variable.rfsrc

    Examples

    Run this code
    ## Not run: 
    # ## ------------------------------------------------------------
    # ## survival/competing risk
    # ## ------------------------------------------------------------
    # 
    # ## survival
    # data(veteran, package = "randomForestSRC")
    # v.obj <- rfsrc(Surv(time,status)~., veteran, nsplit = 10, ntree = 100)
    # partial.obj <- partial.rfsrc(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.rfsrc(follic.obj,
    #   partial.type = "cif",
    #   partial.xvar = "age",
    #   partial.values = follic.obj$xvar[, "age"],
    #   partial.time = follic.obj$time.interest,
    #   oob = TRUE)
    # 
    # ## regression
    # airq.obj <- rfsrc(Ozone ~ ., data = airquality)
    # partial.obj <- partial.rfsrc(airq.obj,
    #   partial.xvar = "Wind",
    #   partial.values = airq.obj$xvar[, "Wind"],
    #   oob = FALSE)
    # 
    # ## classification
    # iris.obj <- rfsrc(Species ~., data = iris)
    # partial.obj <- partial.rfsrc(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.rfsrc(mtcars.mix,
    #   partial.xvar = "disp",
    #   partial.values = mtcars.mix$xvar[, "disp"])
    # ## End(Not run)
    

    Run the code above in your browser using DataLab