I am using the ‘dismo’ package to conduct boosted regression trees (BRT) for both binary and count data. The dismo package uses ‘gbm’ package for the implementation of BRT. I would like to incorporate two offset terms in the model, as well as being able to make predictions.
For the count data I am using a Poisson model. Based on a previous post (https://stat.ethz.ch/pipermail/r-help/2010-September/253647.html), I implemented the following code:
library(gbm)
library(dismo)
define offset
offset=(log(data$off1)+ log(data$off2)) #equivalent to log(data$off1*data$off2)
Dear Harry,
I am using the ‘dismo’ package to conduct boosted regression trees (BRT) for both binary and count data. The dismo package uses ‘gbm’ package for the implementation of BRT. I would like to incorporate two offset terms in the model, as well as being able to make predictions. For the count data I am using a Poisson model. Based on a previous post (https://stat.ethz.ch/pipermail/r-help/2010-September/253647.html), I implemented the following code:
library(gbm) library(dismo)
define offset
offset=(log(data$off1)+ log(data$off2)) #equivalent to log(data$off1*data$off2)
fit poisson
m.pois<-gbm.step(data=data, gbm.x=7:8, gbm.y=4, offset=offset, family="poisson", tree.complexity=1, learning.rate=0.001, bag.fraction=0.7, n.folds=10)
predict poisson
link <-predict.gbm(m.pois, data, n.trees=n.trees, type="link") link.offset<- link + offset pred <- exp(link.offset)
My questions is how to implement the same for a binomial model? I have tried to look in different forums and documentation without success. The only clue that I have is the following document: https://r-forge.r-project.org/scm/viewvc.php/*checkout*/pkg/inst/doc/gbm.pdf?revision=18&root=gbm&pathrev=22
Any advice and/or additional references on this issue would be more than welcome.
Thank you in advance,