[R-sig-Geo] dismo package- data.frame of fitted function and variable values

Bede-Fazekas Ákos bfalevlist at gmail.com
Wed Jan 13 17:51:49 CET 2016


Dear Robert,
here you go the code that you need, based on the source code of 
gbm.plot() function:

gbm.object<-angaus.tc5.lr01
gbm.call <- gbm.object$gbm.call
data <- gbm.call$dataframe
pred.names <- gbm.call$predictor.names
k <- match("SegSumT",pred.names)
pred.data <- data[ , gbm.call$gbm.x[k]]
response.matrix <- gbm::plot.gbm(gbm.object, k, return.grid = TRUE)
predictors <- response.matrix[,1]
if (is.factor(data[,gbm.call$gbm.x[k]])) {
     predictors <- factor(predictors,levels = 
levels(data[,gbm.call$gbm.x[k]]))
}
responses <- response.matrix[,2] - mean(response.matrix[,2])
data.frame(predictors, responses)

Kind regards,
Ákos Bede-Fazekas
Hungarian Academy of Sciences

2016.01.13. 14:18 keltezéssel, Rob Deg írta:
> Dear R-users,
>
> Iam using the boosted regression trees to model the occurrence of
> presence/absence data by using environmental factors.
> Iam wondering how its possible to print out the data.frame of fitted
> functions and variable values that were used in producing the gbm.plot.
> For example, values of fitted functions (y-axis) and SegSumT (x-axis) from
> the following plot provided in the dismo package example
>
> ======================
> library(dismo)
> data(Anguilla_train)
> Anguilla_train = Anguilla_train[1:200,]
> angaus.tc5.lr01 <- gbm.step(data=Anguilla_train, gbm.x = 3:14, gbm.y = 2,
> family = "bernoulli", tree.complexity = 5, learning.rate = 0.01,
> bag.fraction = 0.5)
> gbm.plot(angaus.tc5.lr01)
>
> =========================
>
> Best,
>
> Robert
>
> 	[[alternative HTML version deleted]]
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



More information about the R-sig-Geo mailing list