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

response(fitted()) and fitted(, type = response) in mboostLSS.R #5

Closed sbrockhaus closed 9 years ago

sbrockhaus commented 9 years ago

This is just a question of understandig some of your code:

In the file mboostLSS.R it says in Code line 159ff:

## update value of nuisance parameters
## use response(fitted()) as this is much quicker than fitted(, type = response)
 for (k in mods[-j])
     assign(names(fit)[k], families[[k]]@response(fitted(fit[[k]])),
                environment(get("ngradient", environment(fit[[j]]$subset))))

And consequently response(fitted()) is used.

I just wondered whether there is a reason, that in line 130 fitted(, type = response) is used instead of response(fitted())? The corresponding code ist:

for (k in mods[-j]){
    if (!is.null(fit[[k]]))
          assign(names(fit)[k], fitted(fit[[k]], type = "response"),
               environment(families[[j]]@ngradient))
}

Best

hofnerb commented 9 years ago

Dear Sarah,

very good question.

The reason for changing fitted(, type = response) to response(fitted()) in lines 159ff was that fitted(, type = response) actually calls predict(, type = response) and thus needs to do all computations anew while fitted() simply returns the current accumulated fit.

If we predict in line 130, this is not such a problem as we only have offset models so far. In 159ff we have models with potentially many boosting steps (depending on the current iteration).

Having said this, I think it is not really necessary to change line 130 but it doesn't hurt either. For consistency, we thus modified the code.

sbrockhaus commented 9 years ago

Thanks a lot for the explanations!