Predicts the response for new data using a fitted SDTree.

# S3 method for class 'SDTree'
predict(object, newdata, ...)

Arguments

object

Fitted object of class SDTree.

newdata

New test data of class data.frame containing the covariates for which to predict the response.

...

Further arguments passed to or from other methods.

Value

A vector of predictions for the new data.

See also

Author

Markus Ulmer

Examples

set.seed(1)
n <- 10
X <- matrix(rnorm(n * 5), nrow = n)
y <- sign(X[, 1]) * 3 + rnorm(n)
model <- SDTree(x = X, y = y, Q_type = 'no_deconfounding', cp = 0.5)
predict(model, newdata = data.frame(X))
#>         1         2         3         4         5         6         7         8 
#> -1.405491 -1.405491 -1.405491  2.892405  2.892405 -1.405491  2.892405  2.892405 
#>         9        10 
#>  2.892405 -1.405491