gpdSeqTests: GPD Multiple Threshold Goodness-of-Fit Testing

View source: R/gpdSeqTests.R

gpdSeqTestsR Documentation

GPD Multiple Threshold Goodness-of-Fit Testing

Description

Wrapper function to test multiple thresholds for goodness-of-fit to the Generalized Pareto model. Can choose which test to run from the available tests in this package.

Usage

gpdSeqTests(
  data,
  thresholds = NULL,
  nextremes = NULL,
  method = c("ad", "cvm", "pbscore", "multscore", "imasym", "impb"),
  nsim = NULL,
  inner = NULL,
  outer = NULL,
  information = c("expected", "observed"),
  allowParallel = FALSE,
  numCores = 1
)

Arguments

data

Original, full dataset in vector form.

thresholds

A set of candidate threshold values (either this or a set of the number of extremes must be given, but not both). Must be provided as a vector.

nextremes

A set of candidate numbers of upper extremes to be used, provided as a vector.

method

Which test to run to sequentially test the thresholds. Must be one of ‘ad’, ‘cvm’, ‘pbscore’, ‘multscore’, ‘imasym’, or ‘impb’.

nsim

Number of boostrap replicates for the ‘ad’, ‘cvm’, ‘pbscore’, ‘multscore’, and ‘imasym’ tests.

inner

Number of inner boostrap replicates if ‘impb’ test is chosen.

outer

Number of outer boostrap replicates if ‘impb’ test is chosen.

information

To use observed or expected (default) information for the ‘pbscore’ and ‘multscore’ tests.

allowParallel

If selected, should the ‘cvm’, ‘ad’, ‘pbscore’, or ‘impb’ procedure be run in parallel or not. Defaults to false.

numCores

If allowParallel is true, specify the number of cores to use.

Details

Function returns a matrix containing the thresholds used, the number of observations above each threshold, the corresponding test statistics, p-values (raw and transformed), and parameter estimates at each threshold. The user must provide the data, a vector of thresholds or number of upper extremes to be used, and select the test. Thresholds are tested in the order supplied. For sequential threshold selection, provide candidate thresholds from lowest to highest. If using nextremes, provide the corresponding numbers of upper extremes in descending order so that the implied thresholds are increasing. At a chosen significance level, rejecting the first k sequential hypotheses means that the first k candidate thresholds are rejected as too low. The next candidate threshold, if not rejected, is the selected threshold. If no adjusted p-value rejects, the first candidate threshold is retained; if all adjusted p-values reject, none of the candidate thresholds is high enough.

Value

threshold

The threshold used for the test.

num.above

The number of observations above the given threshold.

p.values

Raw p-values for the thresholds tested.

ForwardStop

Transformed p-values according to the ForwardStop stopping rule.

StrongStop

Transformed p-values according to the StrongStop stopping rule.

statistic

Returned test statistics of each individual test.

est.scale

Estimated scale parameter for the given threshold.

est.shape

Estimated shape parameter for the given threshold.

Examples

set.seed(7)
x <- rgpd(10000, loc = 0, scale = 5, shape = 0.2)
## Candidate thresholds should be listed from lowest to highest.
candidate_thresholds <- c(1.5, 2.5, 3.5, 4.5, 5.5)
z <- gpdSeqTests(x, thresholds = candidate_thresholds, method = "ad")

## For a 5% ForwardStop rule, rejecting the first k tests rejects
## candidate_thresholds[1:k] as too low.
k <- max(which(z$ForwardStop <= 0.05), 0)
rejected_thresholds <- candidate_thresholds[seq_len(k)]
selected_threshold <- if(k < length(candidate_thresholds)) candidate_thresholds[k + 1] else NA

eva documentation built on June 21, 2026, 9:07 a.m.