Learn R Programming

spm (version 1.2.2)

rgidwpred: Generate spatial predictions using the hybrid method of random forest in ranger and inverse distance weighting (RGIDW)

Description

This function is to make spatial predictions using the hybrid method of random forest in ranger and inverse distance weighting (RGIDW).

Usage

rgidwpred(
  longlat,
  trainx,
  trainy,
  longlatpredx,
  predx,
  mtry = function(p) max(1, floor(sqrt(p))),
  num.trees = 500,
  min.node.size = NULL,
  type = "response",
  num.threads = NULL,
  verbose = FALSE,
  idp = 2,
  nmax = 12,
  ...
)

Arguments

longlat

a dataframe contains longitude and latitude of point samples (i.e., trainx and trainy).

trainx

a dataframe or matrix contains columns of predictive variables.

trainy

a vector of response, must have length equal to the number of rows in trainx.

longlatpredx

a dataframe contains longitude and latitude of point locations (i.e., the centres of grids) to be predicted.

predx

a dataframe or matrix contains columns of predictive variables for the grids to be predicted.

mtry

a function of number of remaining predictor variables to use as the mtry parameter in the randomForest call.

num.trees

number of trees. By default, 500 is used.

min.node.size

Default 1 for classification, 5 for regression.

type

Type of prediction. One of 'response', 'se', 'terminalNodes' with default 'response'. See ranger::predict.ranger for details.

num.threads

number of threads. Default is number of CPUs available.

verbose

Show computation status and estimated runtime.Default is FALSE.

idp

numeric; specify the inverse distance weighting power.

nmax

for local predicting: the number of nearest observations that should be used for a prediction or simulation, where nearest is defined in terms of the space of the spatial locations. By default, 12 observations are used.

...

other arguments passed on to randomForest or gstat.

Value

A dataframe of longitude, latitude and predictions.

References

Wright, M. N. & Ziegler, A. (2017). ranger: A Fast Implementation of Random Forests for High Dimensional Data in C++ and R. J Stat Softw 77:1-17. http://dx.doi.org/10.18637/jss.v077.i01.

Examples

Run this code
# NOT RUN {
data(petrel)
data(petrel.grid)
rgidwpred1 <- rgidwpred(petrel[, c(1,2)], petrel[, c(1,2, 6:9)], petrel[, 3],
petrel.grid[, c(1,2)], petrel.grid, num.trees = 500, idp = 2, nmax = 12)
names(rgidwpred1)
# }
# NOT RUN {
# }

Run the code above in your browser using DataLab