0

This is a follow-up to a previous question I asked a while back that was recently answered.

I have built several gbm models with dismo::gbm.step, which relies on the gbm fitting functions found in R package gbm, as well as cross validation tools from R package splines.

As part of my analysis, I would like to use some of the graphical tools available in R (e. g. perspective plots) to visualize pairwise interactions in the data. Both the gbm and the dismo packages have functions for detecting and modelling interactions in the data.

The implementation in dismo is explained in Elith et. al (2008) and returns a statistic which indicates departures of the model predictions from a linear combination of the predictors, while holding all other predictors at their means.

The implementation in gbm uses Friedman`s H statistic (Friedman & Popescue, 2005), and returns a different metric, and also does NOT set the other variables at their means.

The interactions modelled and plotted with dismo::gbm.interactions are great and have been very informative. However, I would also like to use gbm::interact.gbm, partly for publication strength and also to compare the results from the two methods.

If I try to run gbm::interact.gbm in a gbm.object created with dismo, an error is returned…

"Error in is.factor(data[, x$var.names[j]]) : 
  argument "data" is missing, with no default"

I understand dismo::gmb.step adds extra data the authors thought would be useful to the gbm model.

I also understand that the answer to my question lies somewherein the source code.

My questions is...

  1. Is it possible to modify a gbm object created in dismo to be used in gbm::gbm.interact? If so, would this be accomplished by...

    a. Modifying the gbm object created in dismo::gbm.step?

    b. Modifying the source code for gbm::interact.gbm?

    c. Doing something else?

I will be going through the source code trying to solve this myself, if I come up with a solution before anyone answers I will answer my own question.

Community
  • 1
  • 1
GNG
  • 239
  • 2
  • 11

1 Answers1

-1

The gbm::interact.gbm function requires data as an argument interact.gbm <- function(x, data, i.var = 1, n.trees = x$n.trees).

The dismo gbm.object is essentially the same as the gbm gbm.object, but with extra information attached so I don't imagine changing the gbm.object would help.

at888
  • 1
  • 4
  • This does not provide an answer to the question. To critique or request clarification from an author, leave a comment below their post - you can always comment on your own posts, and once you have sufficient [reputation](http://stackoverflow.com/help/whats-reputation) you will be able to [comment on any post](http://stackoverflow.com/help/privileges/comment). - [From Review](/review/low-quality-posts/11376657) – Prune Feb 24 '16 at 01:24
  • Didn't have enough reputation to comment. I'm quite sure it will work if data is specified when calling the function. – at888 Feb 24 '16 at 13:13