[R] fit and predict binomial gbm with two offset terms

David March Morla david at imedea.uib-csic.es
Wed Mar 12 13:25:57 CET 2014


Dear all,

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,

David March

-- 
David March Morlà
Spatial Ecologist
Email: david at imedea.uib-csic.es

IMEDEA
Instituto Mediterraneo de Estudios Avanzados (UIB-CSIC)
C/Miquel Marquès 21, 07190 Esporles, Balearic Islands. Spain
www.imedea.uib.es

SOCIB
Balearic Islands Coastal Observing and Forecasting System
Strategic Issues and Applications for Society (SIAS Division)
Parc Bit, Naorte, Bloc A 2ºp. pta. 3, 07121 Palma de Mallorca. Spain
Tel: +034 971 43 97 64
www.socib.es

SOCIAL MEDIA
Google Scholar: http://scholar.google.es/citations?user=xABsDpAAAAAJ
Research Gate: https://www.researchgate.net/profile/David_March3/
Linked In: http://www.linkedin.com/in/dmarch



More information about the R-help mailing list