From 84d551561fb2086b4877207106c209b936011c9c Mon Sep 17 00:00:00 2001 From: Marvin Wright Date: Thu, 28 Sep 2023 10:04:57 +0200 Subject: [PATCH] lm with intercept --- R/ranger.R | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/R/ranger.R b/R/ranger.R index cf1d346f..33da7f35 100644 --- a/R/ranger.R +++ b/R/ranger.R @@ -829,9 +829,10 @@ ranger <- function(formula = NULL, data = NULL, num.trees = 500, mtry = NULL, confounders <- matrix(c(0, 0)) use.confounders <- FALSE } else if (is.data.frame(confounders)) { - confounders <- data.matrix(confounders) + confounders <- cbind(1, data.matrix(confounders)) use.confounders <- TRUE } else if (is.matrix(confounders)) { + confounders <- cbind(1, confounders) use.confounders <- TRUE } else { stop("Error: confounders argument has to be matrix or data.frame.")