Open
Description
## monotonicity with interaction and factor
library("mboost")
## simulate some data
set.seed(1234)
x1 <- rnorm(1000)
x2 <- sample(1:5, 1000, replace = TRUE)
y <- -x1^3 * (6 - x2) + rnorm(1000, sd = 0.1)
x2 <- as.factor(x2)
## Works with numeric values
x2 <- as.numeric(x2)
mod <- mboost(y ~ bmono(x1, x2, df = 5, constraint = list("decreasing", "increasing")),
control = boost_control(trace = TRUE, mstop = 10))
plot(mod)
## Interaction currently does not work with ordinals
x2 <- as.ordered(x2)
## Does work as single effect
mod2 <- mboost(y ~ bmono(x2, constraint = "decreasing"))
plot(mod2)
## Doesn't work
mod3 <- mboost(y ~ bmono(x1, x2, df = 5, constraint = list("decreasing", "increasing")),
control = boost_control(trace = TRUE, mstop = 10))
## Error in seq.default(boundary.knots[1] - degree * dx, boundary.knots[1], :
## 'from' cannot be NA, NaN or infinite
Of note:
x1 <- as.ordered(x1)
x2 <- as.ordered(x2)
mod <- mboost(y ~ bmono(x1, x2, constraint = list("decreasing", "increasing")))
## Error in bl_mono(ret, Xfun = X_ols, args = args) :
## Bivariate monotonic effects currently not implemented for ordered factors
Metadata
Metadata
Assignees
Labels
No labels