boost-R / mboost

Boosting algorithms for fitting generalized linear, additive and interaction models to potentially high-dimensional data. The current relase version can be found on CRAN (http://cran.r-project.org/package=mboost).
73 stars 27 forks source link

Missing values and weights #80

Closed carlganz closed 7 years ago

carlganz commented 7 years ago

Hello,

I find that that when mboost subsets to remove missing values here it fails to subset the weights so the dimensions don't line up down the road.

Example:

library(mboost)
# generate random data
set.seed(2017-5-22)

weights <- sample(1:100, 100, replace=FALSE)
x <- rnorm(100)
y <- runif(100)

# create missing value
x[25] <- NA

myData <- data.frame(x=x, y=y)

# errors
mboost(
  y ~ bols(x), 
  data = myData,
  weights = weights,
  family = Gaussian()
  )

# works
mboost(
  y ~ bols(x), 
  data = myData,
  weights = weights[-25],
  family = Gaussian()
)

# base R modeling functions subset weights
lm(y ~ x, myData, weights = weights)

Kind Regards, Carl Ganz

hofnerb commented 7 years ago

You are absolutely right. Thanks for the bug report. I will immediately see how we can fix that.