boost-R / gamboostLSS

Boosting models for fitting generalized additive models for location, shape and scale (GAMLSS) to potentially high dimensional data. The current relase version can be found on CRAN (https://cran.r-project.org/package=gamboostLSS).
26 stars 11 forks source link

mboost_LSS does not work for "matrix valued, but scalar" responses fit with FDboost #52

Closed fabian-s closed 5 years ago

fabian-s commented 5 years ago

because this:

https://github.com/boost-R/gamboostLSS/blob/f97c8906fc9d78e05cb28823789b12cd31c06fdc/R/mboostLSS.R#L171

turns matrices of scalar wins/losses, e.g., into a long vector.

sbrockhaus commented 5 years ago

can you provide a MWE?

fabian-s commented 5 years ago
y <- cbind(1:10, 10:1)
x <- matrix(runif(11 *10), 11, 10)
library(gamlss.dist)
#> Loading required package: MASS
library(FDboost)
#> Loading required package: mboost
#> Loading required package: parallel
#> Loading required package: stabs
#> This is mboost 2.9-0. See 'package?mboost' and 'news(package  = "mboost")'
#> for a complete list of changes.
#> 
#> Attaching package: 'mboost'
#> The following object is masked from 'package:gamlss.dist':
#> 
#>     Family
#> This is FDboost 0.3-1.

FDboost(y ~ bsignal(x), timeformula = NULL, family = gamboostLSS::as.families(BI),
        data = list(x=x, y = y))
#> Warning in gamboostLSS::as.families(BI): For boosting one-parametric
#> families, please use the mboost package.
#> Error in FDboost(y ~ bsignal(x), timeformula = NULL, family = gamboostLSS::as.families(BI), : The length of the response and number of observations of x do not match.

Created on 2019-03-16 by the reprex package (v0.2.0).

Session info ``` r devtools::session_info() #> ─ Session info ────────────────────────────────────────────────────────── #> setting value #> version R version 3.4.4 (2018-03-15) #> os Ubuntu 14.04.5 LTS #> system x86_64, linux-gnu #> ui X11 #> language (EN) #> collate en_US.UTF-8 #> ctype en_US.UTF-8 #> tz Europe/Amsterdam #> date 2019-03-16 #> #> ─ Packages ────────────────────────────────────────────────────────────── #> package * version date lib source #> assertthat 0.2.0 2017-04-11 [1] CRAN (R 3.4.2) #> backports 1.1.2 2017-12-13 [1] CRAN (R 3.4.4) #> BBmisc 1.11 2017-03-10 [1] CRAN (R 3.4.4) #> callr 2.0.4 2018-05-15 [1] CRAN (R 3.4.4) #> checkmate 1.8.5 2017-10-24 [1] CRAN (R 3.4.2) #> classiFunc 0.1.1 2018-04-16 [1] CRAN (R 3.4.4) #> cli 1.0.0 2017-11-05 [1] CRAN (R 3.4.3) #> coda 0.19-1 2016-12-08 [1] CRAN (R 3.4.2) #> codetools 0.2-15 2016-10-05 [4] CRAN (R 3.3.1) #> crayon 1.3.4 2017-09-16 [1] CRAN (R 3.4.2) #> debugme 1.1.0 2017-10-22 [1] CRAN (R 3.4.3) #> desc 1.2.0 2018-05-01 [1] CRAN (R 3.4.4) #> devtools 2.0.1 2018-10-26 [1] CRAN (R 3.4.4) #> digest 0.6.15 2018-01-28 [1] CRAN (R 3.4.4) #> doParallel 1.0.11 2017-09-28 [1] CRAN (R 3.4.2) #> dotCall64 0.9-5.2 2018-01-11 [1] CRAN (R 3.4.4) #> dtw 1.20-1 2018-05-18 [1] CRAN (R 3.4.4) #> evaluate 0.11 2018-07-17 [1] CRAN (R 3.4.4) #> fda 2.4.8 2018-07-05 [1] CRAN (R 3.4.4) #> fda.usc 1.4.0 2018-02-14 [1] CRAN (R 3.4.4) #> fdasrvf 1.8.3 2017-12-17 [1] CRAN (R 3.4.4) #> FDboost * 0.3-1 2017-10-31 [1] git (@bab8082) #> fields 9.6 2018-01-29 [1] CRAN (R 3.4.4) #> foreach 1.4.4 2017-12-12 [1] CRAN (R 3.4.4) #> Formula 1.2-3 2018-05-03 [1] CRAN (R 3.4.4) #> fs 1.2.5 2018-07-30 [1] CRAN (R 3.4.4) #> gamboostLSS 2.0-1 2018-06-15 [1] CRAN (R 3.4.4) #> gamlss.dist * 5.1-1 2018-12-08 [1] CRAN (R 3.4.4) #> glue 1.3.0 2018-07-17 [1] CRAN (R 3.4.4) #> htmltools 0.3.6 2017-04-28 [1] CRAN (R 3.4.2) #> inum 1.0-0 2017-12-12 [1] CRAN (R 3.4.4) #> iterators 1.0.10 2018-07-13 [1] CRAN (R 3.4.4) #> knitr 1.20 2018-02-20 [1] CRAN (R 3.4.4) #> lattice 0.20-35 2017-03-25 [1] CRAN (R 3.4.2) #> libcoin 1.0-1 2017-12-13 [1] CRAN (R 3.4.4) #> magrittr 1.5 2014-11-22 [1] CRAN (R 3.4.2) #> maps 3.3.0 2018-04-03 [1] CRAN (R 3.4.4) #> MASS * 7.3-50 2018-04-30 [1] CRAN (R 3.4.4) #> Matrix 1.2-14 2018-04-09 [1] CRAN (R 3.4.4) #> matrixcalc 1.0-3 2012-09-15 [1] CRAN (R 3.4.2) #> mboost * 2.9-0 2018-06-13 [1] CRAN (R 3.4.4) #> memoise 1.1.0 2017-04-21 [1] CRAN (R 3.4.2) #> mgcv 1.8-24 2018-06-18 [1] CRAN (R 3.4.4) #> mvtnorm 1.0-8 2018-05-31 [1] CRAN (R 3.4.4) #> nlme 3.1-137 2018-04-07 [1] CRAN (R 3.4.4) #> nnls 1.4 2012-03-19 [1] CRAN (R 3.4.2) #> partykit 1.2-2 2018-06-05 [1] CRAN (R 3.4.4) #> pkgbuild 1.0.2 2018-10-16 [1] CRAN (R 3.4.4) #> pkgload 1.0.2 2018-10-29 [1] CRAN (R 3.4.4) #> prettyunits 1.0.2 2015-07-13 [1] CRAN (R 3.4.3) #> processx 3.1.0 2018-05-15 [1] CRAN (R 3.4.4) #> proxy 0.4-22 2018-04-08 [1] CRAN (R 3.4.4) #> quadprog 1.5-5 2013-04-17 [1] CRAN (R 3.4.2) #> R6 2.3.0 2018-10-04 [1] CRAN (R 3.4.4) #> Rcpp 1.0.0 2018-11-07 [1] CRAN (R 3.4.4) #> remotes 2.0.2 2018-10-30 [1] CRAN (R 3.4.4) #> rlang 0.2.2 2018-08-16 [1] CRAN (R 3.4.4) #> rmarkdown 1.10 2018-06-11 [1] CRAN (R 3.4.4) #> rpart 4.1-13 2018-02-23 [1] CRAN (R 3.4.4) #> rprojroot 1.3-2 2018-01-03 [1] CRAN (R 3.4.4) #> rucrdtw 0.1.3 2017-10-13 [1] CRAN (R 3.4.4) #> sessioninfo 1.1.1 2018-11-05 [1] CRAN (R 3.4.4) #> spam 2.2-0 2018-06-19 [1] CRAN (R 3.4.4) #> stabs * 0.6-3 2017-07-19 [1] CRAN (R 3.4.2) #> stringi 1.2.4 2018-07-20 [1] CRAN (R 3.4.4) #> stringr 1.3.1 2018-05-10 [1] CRAN (R 3.4.4) #> survival 2.42-6 2018-07-13 [1] CRAN (R 3.4.4) #> testthat 2.0.0 2017-12-13 [1] CRAN (R 3.4.4) #> usethis 1.4.0 2018-08-14 [1] CRAN (R 3.4.4) #> viridisLite 0.3.0 2018-02-01 [1] CRAN (R 3.4.4) #> withr 2.1.2 2018-04-24 [1] Github (jimhester/withr@79d7b0d) #> yaml 2.1.19 2018-05-01 [1] CRAN (R 3.4.4) #> zoo 1.8-3 2018-07-16 [1] CRAN (R 3.4.4) #> #> [1] /home/fabians/R/x86_64-pc-linux-gnu-library/3.4 #> [2] /usr/local/lib/R/site-library #> [3] /usr/lib/R/site-library #> [4] /usr/lib/R/library ```
sbrockhaus commented 5 years ago

So this issue is about the BI family to fit a model for a Binomial distribution with different numbers of tries, such that the response has to be provided as a matrix? Or do you also have other cases in mind? I had a look at your example, and changed some of the data generating process and added the domain of the functional covariate. The following code works fine for me (FDboost 0.3-2. and mboost 2.9-1). I admit that the warnings are not beautiful, but as far as I can see, you can ignore them.

## use n = 11 obersvations, 
## make sure that in y, the number in the first column is smaller than that in the second column

y <- cbind(rep(1, 11), 11:1)
 x <- matrix(runif(11 *10), 11, 10)
 xs <- seq(0, 1, l = 10)

 library(gamlss.dist)
# Lade nötiges Paket: MASS
# Warning message:
# Paket ‘gamlss.dist’ wurde unter R Version 3.5.3 erstellt 

 library(FDboost)

# Lade nötiges Paket: mboost
# Lade nötiges Paket: parallel
# Lade nötiges Paket: stabs
# This is mboost 2.9-1. See ‘package?mboost’ and ‘news(package  = "mboost")’
# for a complete list of changes.
#
# Attache Paket: ‘mboost’
# 
# The following object is masked from ‘package:gamlss.dist’:
# 
#    Family
# 
# This is FDboost 0.3-2. 
# Warning message:
# Paket ‘mboost’ wurde unter R Version 3.5.3 erstellt 

m <- FDboost(y ~ bsignal(x, xs), timeformula = NULL, family = gamboostLSS::as.families(BI),  
                        data = list(x=x, y = y, xs = xs))

# x is not centered per column, inducing a non-centered effect.
# Warning messages:
# 1: In gamboostLSS::as.families(BI) :
#   For boosting one-parametric families, please use the mboost package.
# 2: In df2lambda(X, df = args$df, lambda = args$lambda, dmat = K, weights = w,  :
#   estimated degrees of freedom differ from ‘df’ by 1.5274922660069e-08
# 3: In gamboostLSS::as.families(BI) :
#   For boosting one-parametric families, please use the mboost package.

Can you give it a try and let me know if you still have troubles?

fabian-s commented 5 years ago

thx, sorry, must have been caused by the missing xs argument.....

going forward, just ignore the grumpy old man muttering in the corner.