Skip to content

Error in residuals(<mod>) with scalar on function regression #27

@LucasKook

Description

@LucasKook

Problem description

In the FDboost() example on scalar-on-function regression, calling residuals(mod2) throws an error complaining that

Error in matrix(object$resid(), nrow = object$ydim[1]) : 
  non-numeric matrix extent

since for one-dimensional responses, object$ydim[1] is NULL. mod$resid() itself works fine.

Reprex

Here is the example code:

library("FDboost")

data("fuelSubset", package = "FDboost")

## center the functional covariates per observed wavelength
fuelSubset$UVVIS <- scale(fuelSubset$UVVIS, scale = FALSE)
fuelSubset$NIR <- scale(fuelSubset$NIR, scale = FALSE)

## to make mboost:::df2lambda() happy (all design matrix entries < 10)
## reduce range of argvals to [0,1] to get smaller integration weights
fuelSubset$uvvis.lambda <- with(fuelSubset, (uvvis.lambda - min(uvvis.lambda)) /
  (max(uvvis.lambda) - min(uvvis.lambda)))
fuelSubset$nir.lambda <- with(fuelSubset, (nir.lambda - min(nir.lambda)) /
  (max(nir.lambda) - min(nir.lambda)))

## model fit with scalar response
## include no intercept as all base-learners are centered around 0
mod2 <- FDboost(
  heatan ~ bsignal(UVVIS, uvvis.lambda, knots = 40, df = 4, check.ident = FALSE)
    + bsignal(NIR, nir.lambda, knots = 40, df = 4, check.ident = FALSE),
  timeformula = NULL, data = fuelSubset, control = boost_control(mstop = 200)
)

residuals(mod2)

Session Info

R version 4.4.2 (2024-10-31)
Platform: x86_64-pc-linux-gnu
Running under: Ubuntu 22.04.5 LTS

Matrix products: default
BLAS:   /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.10.0 
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0

locale:
 [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C               LC_TIME=de_AT.UTF-8       
 [4] LC_COLLATE=en_US.UTF-8     LC_MONETARY=de_AT.UTF-8    LC_MESSAGES=en_US.UTF-8   
 [7] LC_PAPER=de_AT.UTF-8       LC_NAME=C                  LC_ADDRESS=C              
[10] LC_TELEPHONE=C             LC_MEASUREMENT=de_AT.UTF-8 LC_IDENTIFICATION=C       

time zone: Europe/Vienna
tzcode source: system (glibc)

attached base packages:
[1] parallel  stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] FDboost_1.1-2  mboost_2.9-11  stabs_0.6-4    nvimcom_0.9.58

loaded via a namespace (and not attached):
 [1] Formula_1.2-5     mgcv_1.9-1        Matrix_1.7-0      lattice_0.22-5    inum_1.0-5       
 [6] rpart_4.1.23      splines_4.4.2     zoo_1.8-12        libcoin_1.0-10    nnls_1.6         
[11] mvtnorm_1.3-2     gamboostLSS_2.0-7 partykit_1.2-20   grid_4.4.2        compiler_4.4.2   
[16] tools_4.4.2       nlme_3.1-165      survival_3.7-0    quadprog_1.5-8    MASS_7.3-60.2    

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions