You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It's awesome that predicts::partialResponse() works for different types of models, but there are still some glitches. For categorial variables in a GBM, the result is a constant, unlike with gbm::plot.gbm():
library(gbm)
library(predicts)
N <- 1000
set.seed(1)
X1 <- runif(N)
set.seed(2)
X2 <- runif(N)
set.seed(3)
X3 <- ordered(sample(letters[1:4], N, replace = TRUE), levels = letters[4:1])
mu <- c(-1, 0, 1, 2)[as.numeric(X3)]
Y <- X1 ^ 1.5 + 2 * (X2 ^ 0.5) + mu
data <- data.frame(Y, X1, X2, X3)
head(data)
mod_gbm <- gbm(Y ~ X1 + X2 + X3, data = data)
partialResponse(mod_gbm, var = "X3", data = data)
# X3 p
# 1 d 2.304339
# 2 c 2.304339
# 3 b 2.304339
# 4 a 2.304339
plot.gbm(mod_gbm, i.var = "X3", return.grid = TRUE)
# X3 y
# 1 d 0.8268557
# 2 c 1.7450856
# 3 b 2.7247473
# 4 a 3.6364649
Categorical variables seem to be analysed correctly e.g. for GLM:
mod_glm <- glm(Y ~ X1 + X2 + X3, data = data)
partialResponse(mod_glm, var = "X3", data = data)
# X3 p
# 1 d 0.7212272
# 2 c 1.7217522
# 3 b 2.7182770
# 4 a 3.7356409
The text was updated successfully, but these errors were encountered:
It's awesome that
predicts::partialResponse()
works for different types of models, but there are still some glitches. For categorial variables in a GBM, the result is a constant, unlike withgbm::plot.gbm()
:Categorical variables seem to be analysed correctly e.g. for GLM:
The text was updated successfully, but these errors were encountered: