Monotonic regression

Example usage 1

library(misc)

# Strict decreasing with SCAM
x <- 1:5
y <- c(0.98, 0.99, 0.97, 0.975, 0.8)

# XGBoost with strict post-hoc enforcement
(result_xgb <- misc::monotonic_regression(x, y, method = "xgboost", monotonicity = -1, strict = TRUE))
## $fitted
## [1] 0.9844955 0.9844955 0.9726248 0.9726248 0.8012921
## 
## $model
## ##### xgb.Booster
## call:
##   xgboost::xgb.train(params = params, data = dtrain, nrounds = 100)
## # of features: 1 
## # of rounds:  100
# LightGBM with default approximate constraints
#(result_lgb <- misc::monotonic_regression(x, y, method = "lightgbm", monotonicity = -1, strict = FALSE))