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

bug in cvrisk.mboostLSS() if families at default #9

Closed sbrockhaus closed 8 years ago

sbrockhaus commented 8 years ago

If the families argument is not specified explicitly in mboostLSSone gets an error in cvrisk.mboostLSS() (spotted by Almond Stöcker). See the following MWP:

library(gamboostLSS)

### Data generating process:
set.seed(1907)
x1 <- rnorm(1000)
mu    <- 2*x1
sigma <- rep(1, 1000)
y <- numeric(1000)
for( i in 1:1000)
       y[i] <- rnorm(1, mean = mu[i], sd=sigma[i])

dat <- data.frame(x1=x1, y=y)

## model with default families 
model <- mboostLSS(y ~ bbs(x1), data = dat)

## cvrisk.mboostLSS() does not work as families was not specified in model call
cvr <- cvrisk(model, folds = cv(model.weights(model), B=3), trace=FALSE)

## model with families = GaussianLSS()
model2 <- mboostLSS(y ~ bbs(x1), families = GaussianLSS())

## works as families was specified in model call
cvr2 <- cvrisk(model2, folds = cv(model.weights(model2), B=3), trace=FALSE)

I think that a possible fix is to define familiesin clin mboostLSS after line https://github.com/hofnerb/gamboostLSS/blob/master/pkg/R/mboostLSS.R#L8 by adding

if(is.null(cl$families)) cl$families <- GaussianLSS()

Best