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

Gamboost base level coefficient #104

Open RossA24 opened 4 years ago

RossA24 commented 4 years ago

I have recently been working with mboost, especially gamboost, for the first time. For a deeper understanding of how the algorithm works, I calculated the first iterations of a basic example manually using categorical data and only a single linear base learner. There were some differences between the coefficients I calculated and the ones mboost provides. It seems like mboost provides the „bare“ coefficients and replaces the base level coefficient with zero. I was expecting all coefficients to be corrected in perspective to the base level. Here is short example:

`library(mboost)

x<-as.factor(mtcars$carb) y<-mtcars$mpg*10

GAM<-gamboost(y~bols(x, intercept = FALSE), family = Poisson())

coef(GAM[1])

nu<-0.1 OffsetWert<-log(mean(y), base = exp(1)) negGradient<-y-exp(OffsetWert) mtcars_neu<-data.frame(mtcars, negGradient) Koef_mtcars<-aggregate(mtcars_neu$negGradient, list(mtcars_neu$carb), mean)

The coefficients mboost provides seem to be the following:

Koef_mtcars$x*nu

I was expecting the standardized coefficients to be as follow:

I use subtraction instead of division because we're using a loglink function

Umnormierte_Koef<-(Koef_mtcars$x-Koef_mtcars$x[1])*nu Umnormierte_Koef`

I would be happy about any help or hints to solve the problem!