The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
Package for boosting regression quantiles (Bauer, Haupt, & Linner, 2023). The functionality as well as the implementation was heavily inspired by the great package for model-based boosting mboost. Until now, only the linear baselearner (brq) is implemented, the nonlinear baselearner (brqss) will follow soon.
You can install the development version of boostrq from GitHub with:
# install.packages("devtools")
::install_github("stefanlinner/boostrq") devtools
The following demonstrates the basic functionality of the package with a simple example.
### Attaching the package to the search path
library(boostrq)
#> Lade nötiges Paket: mboost
#> Lade nötiges Paket: parallel
#> Lade nötiges Paket: stabs
### Fitting your first boosting regression quantiles model.
<-
boosted.rq boostrq(
formula = mpg ~ brq(cyl * hp) + brq(am + wt), # all common formula operators (*,:,^, etc.) can be used in the function brq()
data = mtcars,
mstop = 200,
nu = 0.1,
tau = 0.5
)
### Get some basic information about your model
$formula # the model formula
boosted.rq#> mpg ~ brq(cyl * hp) + brq(am + wt)
#> <environment: 0x000002d865949d38>
$nu # the learning rate
boosted.rq#> [1] 0.1
$offset # the initialization of the algorithm (default: median of response)
boosted.rq#> 50%
#> 19.2
$baselearner.names # names of the baselearners
boosted.rq#> [1] "brq(cyl * hp)" "brq(am + wt)"
$call # the model call
boosted.rq#> boostrq(formula = mpg ~ brq(cyl * hp) + brq(am + wt), data = mtcars,
#> mstop = 200, nu = 0.1, tau = 0.5)
$mstop() # current number of iterations
boosted.rq#> [1] 200
# or use
mstop(boosted.rq)
#> [1] 200
### Print your fitted model to get a collection of that basic information
boosted.rq#>
#> Boosting Regression Qauntiles
#>
#> Call: boostrq(formula = mpg ~ brq(cyl * hp) + brq(am + wt), data = mtcars, mstop = 200, nu = 0.1, tau = 0.5)
#> formula: mpg ~ brq(cyl * hp) + brq(am + wt)
#>
#>
#> Quantile Regression
#> Loss Function: tau * (y - f) * ((y - f) > 0) +
#> (tau - 1) * (y - f) * ((y - f) <= 0)
#> Negative Gradient: tau * ((y - f) > 0) + (tau - 1) * ((y - f) <= 0)
#>
#> Number of boosting iterations: mstop = 200
#> Step size: = 0.1
#> Offset: 19.2
#> Number of baselearners: 2
### Selection frequency of each component
$selection.freqs()
boosted.rq#> Intercept brq(cyl * hp) brq(am + wt)
#> 0.025 0.645 0.330
### Estimated coefficients for current number of iterations
$coef(aggregate = "sum") # also try aggregate = "cumsum" or "none"
boosted.rq#> $`brq(cyl * hp)`
#> (Intercept) cyl hp cyl:hp
#> 19.33792010 -2.47917356 -0.09859763 0.01061430
#>
#> $`brq(am + wt)`
#> (Intercept) am wt
#> 3.133808 1.861487 -1.167737
#>
#> $offset
#> 50%
#> 19.2
# or use
coef(boosted.rq, aggregate = "sum")
#> $`brq(cyl * hp)`
#> (Intercept) cyl hp cyl:hp
#> 19.33792010 -2.47917356 -0.09859763 0.01061430
#>
#> $`brq(am + wt)`
#> (Intercept) am wt
#> 3.133808 1.861487 -1.167737
#>
#> $offset
#> 50%
#> 19.2
### Printing result summaries
summary(boosted.rq)
#>
#> Boosting Regression Qauntiles
#>
#> Call: boostrq(formula = mpg ~ brq(cyl * hp) + brq(am + wt), data = mtcars, mstop = 200, nu = 0.1, tau = 0.5)
#> formula: mpg ~ brq(cyl * hp) + brq(am + wt)
#>
#>
#> Quantile Regression
#> Loss Function: tau * (y - f) * ((y - f) > 0) +
#> (tau - 1) * (y - f) * ((y - f) <= 0)
#> Negative Gradient: tau * ((y - f) > 0) + (tau - 1) * ((y - f) <= 0)
#>
#> Number of boosting iterations: mstop = 200
#> Step size: = 0.1
#> Offset: 19.2
#> Number of baselearners: 2
#>
#> Estimated coefficients:
#> $`brq(cyl * hp)`
#> (Intercept) cyl hp cyl:hp
#> 19.33792010 -2.47917356 -0.09859763 0.01061430
#>
#> $`brq(am + wt)`
#> (Intercept) am wt
#> 3.133808 1.861487 -1.167737
#>
#> $offset
#> 50%
#> 19.2
#>
#>
#> Selection frequencies:
#> Intercept brq(cyl * hp) brq(am + wt)
#> 0.025 0.645 0.330
### Have a look at the underlying baselearner model matrices
$baselearner.matrix()
boosted.rq
### Selected component for each iteration
$xselect()
boosted.rqc("Intercept", boosted.rq$baselearner.names)[boosted.rq$xselect() + 1]
### Current working residuals (negative gradients)
$neg.gradients()
boosted.rq
### Course of empirical risk during the boosting process
$risk()
boosted.rq
### Current fitted values
$fitted()
boosted.rq# or use
fitted(boosted.rq)
### Current residuals
$resid()
boosted.rq# or use
residuals(boosted.rq)
### Model predictions
<- data.frame(
dat.pred cyl = c(4, 6),
hp = c(90, 134),
wt = c(3.125, 2.485),
am = c(1, 0)
)$predict(newdata = dat.pred, aggregate = "sum") # also try aggregate = "cumsum" or "none"
boosted.rq# or use
predict(boosted.rq, newdata = dat.pred, aggregate = "sum")
### Update the number of iterations without to fully refit the model
### If mstop_new > mstop_current: The fitting process will start at the current number of iterations
### If mstop_new < mstop_current: The model result are subsetted, thus, the model is not refitted
### current number of iterations
$mstop()
boosted.rq#> [1] 200
### Update number of iterations
<- boosted.rq[300]
boosted.rq $mstop()
boosted.rq#> [1] 300
# or use
$subset(400)
boosted.rq$mstop()
boosted.rq#> [1] 400
# or use
mstop(boosted.rq) <- 100
$mstop()
boosted.rq#> [1] 100
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.