Learn R Programming

ExtremeRisks (version 0.0.5)

predQuant: Predictive quantile based on the generalized Pareto model

Description

Bayesian Generalize Pareto-based predictive quantile for continuous and discrete predictive distribution conditioned on intermediate and extreme levels.

Usage

predQuant(
  qlev,
  postsamp,
  threshold,
  lb,
  ub,
  type = c("continuous", "discrete"),
  extrapolation = FALSE,
  p,
  k,
  n
)

Value

a double indicating the value of the quantile

Arguments

qlev

double, quantile level

postsamp

a m by 2 matrix with columns containing the posterior samples of scale and shape parameters of the generalized Pareto distribution, respectively

threshold

threshold for the generalized Pareto model, corresponding to the \(n-k\)th order statistic of the sample

lb

double, the lower bound of the admissible region for the quantile value

ub

double, the upper bound of the admissible region for the quantile value

type

data type, either "continuous" or "discrete" for count data.

extrapolation

logical; if TRUE, extrapolate using the threshold stability property

p

scalar tail probability for the extrapolation. Must be smaller than \(k/n\) (only used if extrapolation=TRUE)

k

integer, number of exceedances for the generalized Pareto (only used if extrapolation=TRUE)

n

integer, number of observations in the full sample. Must be greater than k (only used if extrapolation=TRUE)

Examples

Run this code
if (FALSE) {
# generate data
set.seed(1234)
n <- 500
samp <- evd::rfrechet(n,0,3,4)
# set effective sample size and threshold
k <- 50
threshold <- sort(samp,decreasing = TRUE)[k+1]
# preliminary mle estimates of scale and shape parameters
mlest <- evd::fpot(samp, threshold)
# empirical bayes procedure
proc <- estPOT(
  samp,
  k = k,
  pn = c(0.01, 0.005),
  type = "continuous",
  method = "bayesian",
  prior = "empirical",
  start = as.list(mlest$estimate),
  sig0 = 0.1)
# predictive density estimation
yg <- seq(0, 50, by = 2)
nyg <- length(yg)
predDens_int <- predDens(
  yg,
  proc$post_sample,proc$t,
  "continuous",
  extrapolation=FALSE)
predQuant_int <- predQuant(
  0.5,
  proc$post_sample,
  proc$t,
  proc$t + 0.01,
  50,
  "continuous",
  extrapolation = FALSE)
predDens_ext <- predDens(
  yg,
  proc$post_sample,
  proc$t,
  "continuous",
  extrapolation = TRUE,
  p = 0.001,
  k = k,
  n = n)
predQuant_ext <- predQuant(
  0.5,
  proc$post_sample,
  proc$t,
  proc$t + 0.01,
  100,
  "continuous",
  extrapolation = TRUE,
  p = 0.005,
  k = k,
  n = n)
  }

Run the code above in your browser using DataLab