View source: R/spatialGEV_predict.R
spatialGEV_predict | R Documentation |
Draw from the posterior predictive distributions at new locations based on a fitted GEV-GP model
spatialGEV_predict(
model,
locs_new,
n_draw,
type = "response",
X_a_new = NULL,
X_b_new = NULL,
X_s_new = NULL,
parameter_draws = NULL
)
model |
A fitted spatial GEV model object of class |
locs_new |
A |
n_draw |
Number of draws from the posterior predictive distribution |
type |
A character string: "response" or "parameters". The former returns draws from the posterior predictive distribution, and the latter returns parameter draws (all on original scale). |
X_a_new |
|
X_b_new |
|
X_s_new |
|
parameter_draws |
Optional. A |
An object of class spatialGEVpred
, which is a list of the following components:
An n_draw x n_test
matrix pred_y_draws
containing the draws from the posterior predictive
distributions at n_test
new locations
An n_test x 2
matrix locs_new
containing the coordinates of the test data
An n_train x 2
matrix locs_obs
containing the coordinates of the observed data
set.seed(123)
library(SpatialGEV)
n_loc <- 20
a <- simulatedData$a[1:n_loc]
logb <- simulatedData$logb[1:n_loc]
logs <- simulatedData$logs[1:n_loc]
y <- simulatedData$y[1:n_loc]
locs <- simulatedData$locs[1:n_loc,]
n_test <- 5
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(
data = 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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.