R Under development (unstable) (2025-02-23 r87804 ucrt) -- "Unsuffered Consequences" Copyright (C) 2025 The R Foundation for Statistical Computing Platform: x86_64-w64-mingw32/x64 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > ### > # check gamboostLSS() > > require("gamboostLSS") Loading required package: gamboostLSS Loading required package: mboost Loading required package: parallel Loading required package: stabs Attaching package: 'gamboostLSS' The following object is masked from 'package:stats': model.weights > > set.seed(1907) > x1 <- rnorm(1000) > x2 <- rnorm(1000) > x3 <- rnorm(1000) > x4 <- rnorm(1000) > x5 <- rnorm(1000) > x6 <- rnorm(1000) > mu <- exp(1.5 + 0.3 * x1^2 + 0.5 * x2 - 3 * sin(x3) -1 * x4) > sigma <- exp(-0.2 * x4 + 0.2 * x5 + 0.4 * x6) > y <- numeric(1000) > for( i in 1:1000) + y[i] <- rnbinom(1, size = sigma[i], mu = mu[i]) > dat <- data.frame(x1, x2, x3, x4, x5, x6, y) > > model <- gamboostLSS(y ~ ., families = NBinomialLSS(), data = dat, + control = boost_control(mstop = 200)) > > coef(model) $mu $mu$`bbs(x1, df = dfbase)` 1 2 3 4 5 6 1.15444389 0.93545392 0.71693700 0.50042427 0.28570769 0.07534541 7 8 9 10 11 12 -0.11839907 -0.27732534 -0.38543944 -0.43568220 -0.42822230 -0.36389778 13 14 15 16 17 18 -0.24633715 -0.08712615 0.09162068 0.27043065 0.45036699 0.63285562 19 20 21 22 23 24 0.81691754 1.00419548 1.19460230 1.38640560 1.57832862 1.77025957 $mu$`bbs(x2, df = dfbase)` 1 2 3 4 5 -0.3672899730 -0.3558804106 -0.3444700010 -0.3330501469 -0.3215346239 6 7 8 9 10 -0.3097128554 -0.2972908070 -0.2840287756 -0.2698403844 -0.2552168113 11 12 13 14 15 -0.2393630057 -0.2180543348 -0.1868538334 -0.1421989765 -0.0805408343 16 17 18 19 20 -0.0007499829 0.0957227213 0.2045754661 0.3171470556 0.4253103529 21 22 23 24 0.5293373866 0.6314883390 0.7326624536 0.8337638400 $mu$`bbs(x3, df = dfbase)` 1 2 3 4 5 6 1.62690752 1.66179014 1.69621916 1.72718129 1.74723416 1.73977904 7 8 9 10 11 12 1.66796113 1.47592050 1.11762042 0.61818391 0.03382329 -0.54796310 13 14 15 16 17 18 -1.03626818 -1.38264045 -1.58369400 -1.66929673 -1.67606560 -1.63348348 19 20 21 22 23 24 -1.56155293 -1.47222602 -1.37332082 -1.26954035 -1.16391410 -1.05812520 $mu$`bbs(x4, df = dfbase)` 1 2 3 4 5 6 2.55229364 2.24960554 1.94876411 1.65787563 1.38476697 1.13402109 7 8 9 10 11 12 0.90460104 0.69199958 0.48667666 0.27458711 0.04879986 -0.17271442 13 14 15 16 17 18 -0.36207876 -0.50902480 -0.61846342 -0.69684702 -0.75045489 -0.78790732 19 20 21 22 23 24 -0.81606432 -0.83940053 -0.86068781 -0.88116968 -0.90145775 -0.92172844 attr(,"offset") [1] 4.055461 $sigma $sigma$`bbs(x1, df = dfbase)` 1 2 3 4 5 6 -0.030414463 -0.022125589 -0.013853687 -0.005537592 0.003564302 0.013555209 7 8 9 10 11 12 0.022918020 0.029180391 0.030332232 0.026724517 0.021145905 0.015189257 13 14 15 16 17 18 0.010297454 0.008747268 0.011992086 0.020480823 0.032398966 0.046426114 19 20 21 22 23 24 0.061714562 0.077812302 0.094364504 0.111135191 0.128012831 0.144908327 $sigma$`bbs(x2, df = dfbase)` 1 2 3 4 5 6 -1.00531262 -0.89894202 -0.79242158 -0.68500260 -0.57580593 -0.46457100 7 8 9 10 11 12 -0.35361690 -0.24906416 -0.15890635 -0.08197539 -0.01224824 0.05171766 13 14 15 16 17 18 0.11197233 0.16734047 0.20896077 0.23023383 0.22855165 0.21542982 19 20 21 22 23 24 0.20447995 0.20878255 0.22816321 0.25642983 0.28851626 0.32095757 $sigma$`bbs(x3, df = dfbase)` 1 2 3 4 5 6 0.12063541 0.25402927 0.38682572 0.51548480 0.63424539 0.73889098 7 8 9 10 11 12 0.82637001 0.89629039 0.94519456 0.94149973 0.85858322 0.66899777 13 14 15 16 17 18 0.37527216 0.03122394 -0.30529938 -0.58985492 -0.78942381 -0.90269096 19 20 21 22 23 24 -0.94431872 -0.93456023 -0.89272664 -0.83376343 -0.76851225 -0.70247345 $sigma$`bbs(x4, df = dfbase)` 1 2 3 4 5 6 0.86989262 0.87994190 0.88853846 0.88929979 0.87589781 0.84275362 7 8 9 10 11 12 0.78591633 0.70378776 0.60586559 0.50846766 0.41948694 0.32797964 13 14 15 16 17 18 0.21454813 0.07793247 -0.07497320 -0.23830307 -0.39954949 -0.55170872 19 20 21 22 23 24 -0.69771926 -0.84192690 -0.98877500 -1.13761935 -1.28717664 -1.43691338 $sigma$`bbs(x5, df = dfbase)` 1 2 3 4 5 -0.0023004787 -0.0022666546 -0.0022291320 -0.0021710973 -0.0020661463 6 7 8 9 10 -0.0018478101 -0.0014703493 -0.0009604533 -0.0003984814 0.0001909118 11 12 13 14 15 0.0008694375 0.0017723944 0.0029451304 0.0043234390 0.0057278955 16 17 18 19 20 0.0070223602 0.0081077392 0.0090216912 0.0098791881 0.0107300395 21 22 23 24 0.0116063909 0.0125359456 0.0134878181 0.0144412248 $sigma$`bbs(x6, df = dfbase)` 1 2 3 4 5 6 -0.21860926 -0.21538642 -0.21197455 -0.20629754 -0.19256417 -0.16763016 7 8 9 10 11 12 -0.12961304 -0.07657484 -0.01111445 0.05578871 0.11239796 0.15326313 13 14 15 16 17 18 0.18085349 0.19695872 0.20194124 0.20159997 0.20232816 0.20546306 19 20 21 22 23 24 0.21031886 0.21775473 0.22809248 0.24020569 0.25283988 0.26553388 attr(,"offset") [1] -1.650591 > > par(mfrow = c(3,2)) > plot(dat$x3, fitted(model$mu, which = "x3"), main = "mu") > lines(sort(dat$x3), - 3 * sin(dat$x3)[order(dat$x3)], col = "red") > plot(dat$x3, fitted(model$sigma, which = "x3"), main = "sigma") > lines(sort(dat$x3), - 3 * sin(dat$x3)[order(dat$x3)], col = "red") > > model[400] LSS Models fitted via Model-based Boosting Call: gamboostLSS(formula = y ~ ., data = dat, families = NBinomialLSS(), control = boost_control(mstop = 200)) Number of boosting iterations (mstop): mu = 400, sigma = 400 Step size: mu = 0.1, sigma = 0.1 Families: Negative Negative-Binomial Likelihood: mu (log link) Loss function: -(lgamma(y + sigma) - lgamma(sigma) - lgamma(y + 1) + sigma * log(sigma) + y * f - (y + sigma) * log(exp(f) + sigma)) Negative Negative-Binomial Likelihood: sigma (log link) Loss function: -(lgamma(y + exp(f)) - lgamma(exp(f)) - lgamma(y + 1) + exp(f) * f + y * log(mu) - (y + exp(f)) * log(mu + exp(f))) > plot(dat$x3, fitted(model$mu, which = "x3"), main = "mu") > lines(sort(dat$x3), - 3 * sin(dat$x3)[order(dat$x3)], col = "red") > plot(dat$x3, fitted(model$sigma, which = "x3"), main = "sigma") > lines(sort(dat$x3), - 3 * sin(dat$x3)[order(dat$x3)], col = "red") > > model[600] LSS Models fitted via Model-based Boosting Call: gamboostLSS(formula = y ~ ., data = dat, families = NBinomialLSS(), control = boost_control(mstop = 200)) Number of boosting iterations (mstop): mu = 600, sigma = 600 Step size: mu = 0.1, sigma = 0.1 Families: Negative Negative-Binomial Likelihood: mu (log link) Loss function: -(lgamma(y + sigma) - lgamma(sigma) - lgamma(y + 1) + sigma * log(sigma) + y * f - (y + sigma) * log(exp(f) + sigma)) Negative Negative-Binomial Likelihood: sigma (log link) Loss function: -(lgamma(y + exp(f)) - lgamma(exp(f)) - lgamma(y + 1) + exp(f) * f + y * log(mu) - (y + exp(f)) * log(mu + exp(f))) > plot(dat$x3, fitted(model$mu, which = "x3"), main = "mu") > lines(sort(dat$x3), - 3 * sin(dat$x3)[order(dat$x3)], col = "red") > plot(dat$x3, fitted(model$sigma, which = "x3"), main = "sigma") > lines(sort(dat$x3), - 3 * sin(dat$x3)[order(dat$x3)], col = "red") > > proc.time() user system elapsed 4.21 0.21 4.42