Dear all,
the help file for predict.gbm  states that "The predictions from gbm do not
include the offset term. The user may add the value of the offset to the
predicted value if desired." I am just not sure how exactly, especially for
a Poisson model, where I believe the offset is multiplicative ?

For example:

library(MASS)

fit1 <- glm(Claims ~ District + Group + Age + offset(log(Holders)),
    data = Insurance, family = poisson)
head(predict(fit1, data = Insurance, type = "response"))

#glm.predict includes the offset:
head(predict(fit1, newdata = Insurance, type = "response"))
#        1         2         3         4         5         6
# 31.86358  35.27587  28.18080 158.87829  53.97772  84.16012


library(gbm)

fit2 <- gbm(Claims ~ District + Group + Age + offset(log(Holders)),
    data = Insurance, distribution ="poisson", n.trees = 600)
head(predict(fit2, newdata = Insurance, type = "response", n.trees=600))

#[1] 0.1378249 0.1378249 0.1314991 0.1284441 0.1389563 0.1389563
#Warning message:
#In predict.gbm(fit2, newdata = Insurance, type = "response", n.trees = 600)
:
#  predict.gbm does not add the offset to the predicted values.

Would the answer be simple multiplication such as:
head(predict(fit2, newdata = Insurance, type = "response",
n.trees=600)*Insurance[,"Holders"])
[1]  27.15151  36.38577  32.34878 215.78607  39.46359  74.48058

Any help would be immensely useful.

Thx,
Markus

        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to