predict.fusedTree {fusedTree}R Documentation

Predict Method for Fused Tree Models

Description

Generates predictions from a fitted fusedTree object using new clinical and omics data.

Usage

## S3 method for class 'fusedTree'
predict(object, newX, newZ, newY, ...)

Arguments

object

An object of class "fusedTree" returned by the fusedTree function.

newX

A matrix of new omics covariates for prediction. Must have the same number of columns (variables) as used in the model fitting.

newZ

A data frame of new clinical covariates for prediction.

newY

A numeric response vector or a Surv object. For linear regression, and logistic regression, newY is only used to store predictions and response values together. For cox regression, newY is used to interpolate the baseline hazard to the event times of the test data.

...

Currently not used. Included for S3 method consistency.

Value

A model-specific prediction object:

See Also

fusedTree for model fitting.

Examples

p = 5 # number of omics variables (low for illustration)
p_Clin = 5 # number of clinical variables
N = 100 # sample size
# simulate from Friedman-like function
g <- function(z) {
  15 * sin(pi * z[,1] * z[,2]) + 10 * (z[,3] - 0.5)^2 + 2 * exp(z[,4]) + 2 * z[,5]
}
set.seed(11)
Z <- as.data.frame(matrix(runif(N * p_Clin), nrow = N))
X <- matrix(rnorm(N * p), nrow = N)            # omics data
betas <- c(1,-1,3,4,2)                         # omics effects
Y <- g(Z) + X %*% betas + rnorm(N)             # continuous outcome
Y <- as.vector(Y)
dat = cbind.data.frame(Y, Z) #set-up data correctly for rpart
rp <- rpart::rpart(Y ~ ., data = dat,
                   control = rpart::rpart.control(xval = 5, minbucket = 10),
                   model = TRUE)
cp = rp$cptable[,1][which.min(rp$cptable[,4])] # best model according to pruning
Treefit <- rpart::prune(rp, cp = cp)
fit <- fusedTree(Tree = Treefit, X = X, Y = Y, Z = Z,
                    LinVars = FALSE, model = "linear",
                    lambda = 10,
                    alpha = 1000)
Preds <- predict(fit, newX = X, newZ = Z, newY = Y)

[Package fusedTree version 1.0.1 Index]