Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

%X% with base-learners that have design matrices with different row numbers #79

Closed
sbrockhaus opened this issue May 8, 2017 · 2 comments

Comments

@sbrockhaus
Copy link
Member

When two base-learners are connected by %X% and one of them has shorter data, the design matrix is simply repeated. See

library(mboost)

mydat <- list(x_10 = 1:10, x_20 = 1:20, y = rnorm(20))

## works without throwing an error / warning, ... 
m1 <- mboost(y ~ bols(x_10) %X% bols(x_20), data = mydat)

## ... as x_10 is simply repeated 
extract(m1)

## see get("%X%")

I was surprised that this does not throw an error or a warning.

This is due to
mf <- cbind(model.frame(bl1), model.frame(bl2))
in
https://github.com/boost-R/mboost/blob/master/R/bl.R#L1043

I would suggest to throw a warning, something like

if (nrow(model.frame(bl1)) != nrow(model.frame(bl2))) 
  warning("The design matrices of the two marginal base-learners imply a different number of rows: ", 
                   nrow(model.frame(bl1)), ", ", nrow(model.frame(bl2)))

But maybe this behavior is intended?

@davidruegamer do you use %X% with differing row numbers?

@sbrockhaus
Copy link
Member Author

btw. bols(x, by = z) behaves in the same way.

mydat <- list(x_10 = 1:10, x_20 = 1:20, y = rnorm(20))

## works without throwing an error / warning, ... 
m2 <- mboost(y ~ bols(x_20, by = x_10), data = mydat)

## ... as x_10 is simply repeated 
extract(m2)

@hofnerb
Copy link
Member

hofnerb commented May 15, 2018

Other base-learners and situations showed the same behavior. See tests/testthat/test-baselearner.R for a detailed list of cases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants