Skip to contents

R arm of the Python modules morie.fn.zx*: learners on the spatial features (covariates plus the coordinates, or a quadratic trend surface) and spatial cross-validation. Zxscv: exact leave-one-out of the trend-surface regression from the hat matrix. Zxsbu: buffered LOO. Zxsbv: spatial block cross-validation (blocks ordered by Philox uniforms, dealt to k folds). Zxsls, Zxsle: lasso and elastic net by coordinate descent (glmnet objective). Zxsqr: quantile regression (QuantileRegressionLp). Zxsrf, Zxsbg: random forest and bagging of CART trees on Philox bootstrap draws. Zxsgb: least-squares gradient boosting. Zxsvm: least-squares SVM with a Gaussian kernel. Zxsen: stacking of the trend model, forest and boosting with non-negative weights from block cross-validation. Zsglm: spatial GLMM simulation (SpatialGlmmSimulate).

Usage

Zxscv(y, X, coords, trend = 1)

Zxsbu(y, X, coords, radius, trend = 1)

Zxsbv(y, X, coords, n_blocks = 3, k = 5, seed = 0, trend = 1)

Zxsls(y, X, coords, lam, trend = 2)

Zxsle(y, X, coords, lam, alpha = 0.5, trend = 2)

Zxsqr(y, X, coords, tau = 0.5, trend = 1)

Zxsrf(
  y,
  X,
  coords,
  n_trees = 100,
  mtry = NULL,
  min_leaf = 5,
  max_depth = NULL,
  seed = 0
)

Zxsbg(y, X, coords, n_trees = 100, min_leaf = 5, max_depth = NULL, seed = 0)

Zxsgb(y, X, coords, n_trees = 100, rate = 0.1, max_depth = 2, min_leaf = 5)

Zxsvm(y, X, coords, gamma = NULL, C = 10)

Zxsen(y, X, coords, n_blocks = 3, k = 5, seed = 0, n_trees = 50)

Zsglm(
  X,
  beta,
  latent,
  family = "poisson",
  trials = 1,
  size = NULL,
  shape = NULL,
  sigma = 1,
  seed = 1
)

Arguments

y

Response.

X

Covariates (without intercept) or NULL.

coords

Locations (n x 2).

trend

Trend-surface degree (1 or 2).

radius

Buffer radius.

n_blocks

Blocks per axis.

k

Folds.

seed

Philox seed.

lam

Penalty.

alpha

Lasso share of the elastic-net penalty.

tau

Quantile level.

n_trees

Trees or boosting rounds.

mtry

Features per split.

min_leaf

Minimum leaf size.

max_depth

Depth cap (NULL for none).

rate

Shrinkage.

gamma

Kernel width (default 1/p).

C

SVM regularisation.

beta, latent, family, trials, size, shape, sigma

GLMM simulation inputs.

Value

A list whose value is the headline number, with the components of the Python result.

References

Roberts, D. R. et al. (2017). Cross-validation strategies for data with temporal, spatial, hierarchical, or phylogenetic structure. Ecography 40, 913-929.

Breiman, L. (2001). Random forests. Machine Learning 45, 5-32.

Hengl, T. et al. (2018). Random forest as a generic framework for predictive modeling of spatial and spatio-temporal variables. PeerJ 6, e5518.

Friedman, J. H. (2001). Greedy function approximation: a gradient boosting machine. Annals of Statistics 29, 1189-1232.

Friedman, J., Hastie, T. and Tibshirani, R. (2010). Regularization paths for generalized linear models via coordinate descent. Journal of Statistical Software 33, 1-22.

Suykens, J. A. K. and Vandewalle, J. (1999). Least squares support vector machine classifiers. Neural Processing Letters 9, 293-300.

Wolpert, D. H. (1992). Stacked generalization. Neural Networks 5, 241-259.

Examples

S <- cbind((0:19 %% 5) / 4, (0:19 %/% 5) / 3)
X <- matrix(((0:19 * 7) %% 11) / 10)
y <- 1 + 2 * X[, 1] + S[, 1] - S[, 2] + ((0:19 * 3) %% 5 - 2) / 10
Zxscv(y, X, S)$value
#> [1] 0.154173
Zxsrf(y, X, S, n_trees = 10, min_leaf = 3, seed = 1)$value
#> [1] 0.6610669