When I use GLMs I can use the option family="Gamma" for analysing data consisting of positive real numbers. Also package gbm provides a large number of distributions to choose from, but there's none that matches the gamma distribution. Which distribution should I choose?

  • 1
    $\begingroup$ take the log of your data and use least squares (=logNormal) ? $\endgroup$
    – Ben Bolker
    May 20, 2014 at 12:28

1 Answer 1


The distribution gamma are available in both gbm (only for the github version https://github.com/gbm-developers/gbm , not in the CRAN version) and mboost package.

For the package gbm, simply specify distribution = 'gamma' in the parameters of gbm function.

For the package mboost, use gamma distribution specifying family = GammaReg() in the options of the function mboost as shown in the toy example below :

n.obs  <- 1000
n.iter <- 100
x1     <- rgamma(n.obs, shape = 1, scale = 1)
x2     <- rgamma(n.obs, shape = 2, scale = 1)
y      <- x1 + x2
model  <- mboost(formula = y ~ x1 + x2, data = data.frame(y, x1, x2),
                 baselearner = "btree", family = GammaReg(), 
                 control = boost_control(mstop = n.iter))
  • 2
    $\begingroup$ It's not too hard to add distributions to gbm. We added gamma at work, and committed it: github.com/harrysouthworth/gbm/blob/master/src/gamma.cpp $\endgroup$ Aug 27, 2016 at 20:03
  • $\begingroup$ Thank you for this precision. I have just edited my answer accordingly. $\endgroup$ Sep 19, 2016 at 13:36
  • $\begingroup$ gamma is also available in the xgboost package. $\endgroup$
    – filups21
    Mar 12, 2021 at 19:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.