spatialGEV_sample: Get posterior parameter draws from a fitted GEV-GP model.

View source: R/spatialGEV_sample.R

spatialGEV_sampleR Documentation

Get posterior parameter draws from a fitted GEV-GP model.

Description

Get posterior parameter draws from a fitted GEV-GP model.

Usage

spatialGEV_sample(model, n_draw, observation = FALSE, loc_ind = NULL)

Arguments

model

A fitted spatial GEV model object of class spatialGEVfit

n_draw

Number of draws from the posterior distribution

observation

whether to draw from the posterior distribution of the GEV observation?

loc_ind

A vector of location indices to sample from. Default is all locations.

Value

An object of class spatialGEVsam, which is a list with the following elements:

parameter_draws

A matrix of joint posterior draws for the hyperparameters and the random effects at the loc_ind locations.

y_draws

If observation == TRUE, a matrix of corresponding draws from the posterior predictive GEV distribution at the loc_ind locations.

Examples


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,]
beta_a <- mean(a); beta_b <- mean(logb)
fit <- spatialGEV_fit(
  data = y,
  locs = locs,
  random = "ab",
  init_param = list(
    beta_a = beta_a,
    beta_b = beta_b,
    a = rep(0, n_loc),
    log_b = rep(0, n_loc),
    s = 0,
    log_sigma_a = 0,
    log_kappa_a = 0,
    log_sigma_b = 0,
    log_kappa_b = 0
  ),
  reparam_s = "positive",
  kernel = "spde",
  silent = TRUE
)

loc_ind <- sample(n_loc, 5)
sam <- spatialGEV_sample(model=fit, n_draw=100,
                         observation=TRUE, loc_ind=loc_ind)

print(sam)
summary(sam)


SpatialGEV documentation built on June 22, 2024, 9:24 a.m.