Predicts the response for new data using a fitted SDForest.
# S3 method for class 'SDForest'
predict(object, newdata, mc.cores = 1, ...)
Fitted object of class SDForest
.
New test data of class data.frame
containing
the covariates for which to predict the response.
Number of cores to use for parallel processing,
if mc.cores > 1
the trees predict in parallel.
Further arguments passed to or from other methods.
A vector of predictions for the new data.
set.seed(1)
n <- 50
X <- matrix(rnorm(n * 5), nrow = n)
y <- sign(X[, 1]) * 3 + rnorm(n)
model <- SDForest(x = X, y = y, Q_type = 'no_deconfounding', nTree = 5, cp = 0.5)
predict(model, newdata = data.frame(X))
#> [1] -1.680850 2.056027 -1.680850 2.056027 2.056027 -1.680850 2.056027
#> [8] 2.056027 2.056027 -1.680850 2.056027 2.056027 -1.680850 -1.680850
#> [15] 2.056027 -1.680850 -1.680850 2.056027 2.056027 2.056027 2.056027
#> [22] 2.056027 2.056027 -1.680850 2.056027 -1.680850 -1.680850 -1.680850
#> [29] -1.680850 2.056027 2.056027 -1.680850 2.056027 -1.680850 -1.680850
#> [36] -1.680850 -1.680850 -1.680850 2.056027 2.056027 -1.680850 -1.680850
#> [43] 2.056027 2.056027 -1.680850 -1.680850 2.056027 2.056027 -1.680850
#> [50] 2.056027