spatialGEV_predict {SpatialGEV} | R Documentation |
Draw from the posterior predictive distributions at new locations based on a fitted GEV-GP model
Description
Draw from the posterior predictive distributions at new locations based on a fitted GEV-GP model
Usage
spatialGEV_predict(
model,
locs_new,
n_draw,
X_a_new = NULL,
X_b_new = NULL,
X_s_new = NULL,
parameter_draws = NULL
)
Arguments
model |
A fitted spatial GEV model object of class |
locs_new |
A |
n_draw |
Number of draws from the posterior predictive distribution |
X_a_new |
|
X_b_new |
|
X_s_new |
|
parameter_draws |
Optional. A |
Value
An object of class spatialGEVpred
, which is a list of the following components:
An
n_draw x n_test
matrixpred_y_draws
containing the draws from the posterior predictive distributions atn_test
new locationsAn
n_test x 2
matrixlocs_new
containing the coordinates of the test dataAn
n_train x 2
matrixlocs_obs
containing the coordinates of the observed data
Examples
set.seed(123)
library(SpatialGEV)
a <- simulatedData$a
logb <- simulatedData$logb
logs <- simulatedData$logs
y <- simulatedData$y
locs <- simulatedData$locs
n_loc <- nrow(locs)
n_test <- 20
test_ind <- sample(1:n_loc, n_test)
# Obtain coordinate matrices and data lists
locs_test <- locs[test_ind,]
y_test <- y[test_ind]
locs_train <- locs[-test_ind,]
y_train <- y[-test_ind]
# Fit the GEV-GP model to the training set
train_fit <- spatialGEV_fit(y = y_train, locs = locs_train, random = "ab",
init_param = list(beta_a = mean(a),
beta_b = mean(logb),
a = rep(0, n_loc-n_test),
log_b = rep(0, n_loc-n_test),
s = 0,
log_sigma_a = 1,
log_kappa_a = -2,
log_sigma_b = 1,
log_kappa_b = -2),
reparam_s = "positive",
kernel = "matern",
silent = TRUE)
pred <- spatialGEV_predict(model = train_fit, locs_new = locs_test, n_draw = 100)
summary(pred)