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 spatialGEVfit

locs_new

A ⁠n_test x 2⁠ matrix containing the coordinates of the new locations

n_draw

Number of draws from the posterior predictive distribution

X_a_new

⁠n_test x r1⁠ design matrix for a at the new locations. If not provided, the default is a column matrix of all 1s.

X_b_new

⁠n_test x r2⁠ design matrix for log(b) at the new locations

X_s_new

⁠n_test x r2⁠ design matrix for (possibly transformed) s at the new locations

parameter_draws

Optional. A ⁠n_draw x n_parameter⁠ matrix. If spatialGEV_sample() has already been called, the output matrix of parameter draws can be supplied here to avoid doing sampling of parameters again. Make sure the number of rows of parameter_draws is the same as n_draw.

Value

An object of class spatialGEVpred, which is a list of the following components:

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)


[Package SpatialGEV version 1.0.0 Index]