Skip to content

Commit c71511b

Browse files
committed
Add maxstable
1 parent a327378 commit c71511b

459 files changed

Lines changed: 29033 additions & 12149 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: mev
22
Type: Package
33
Title: Modelling of Extreme Values
4-
Version: 1.17.10006
4+
Version: 1.17.10007
55
Authors@R: c(person(given="Leo", family="Belzile", role = c("aut", "cre"), email = "belzilel@gmail.com", comment = c(ORCID = "0000-0002-9135-014X")), person(given="Jennifer L.", family="Wadsworth", role=c("aut")), person(given="Paul J.", family="Northrop", role=c("aut"), comment = c(ORCID = "0000-0002-1992-4882")), person(given="Scott D.", family="Grimshaw", role=c("aut"), comment = c(ORCID = "0000-0002-6326-9360")), person(given="Jin", family="Zhang", role=c("ctb")), person(given="Michael A.", family="Stephens", role=c("ctb")), person(given="Art B.", family="Owen", role=c("ctb")), person(given="Raphael", family="Huser", role=c("aut"), comment = c(ORCID = "0000-0002-1228-2071")))
66
Description: Various tools for the analysis of univariate, multivariate and functional extremes. Exact simulation from max-stable processes [Dombry, Engelke and Oesting (2016) <doi:10.1093/biomet/asw008>, R-Pareto processes for various parametric models, including Brown-Resnick (Wadsworth and Tawn, 2014, <doi:10.1093/biomet/ast042>) and Extremal Student (Thibaud and Opitz, 2015, <doi:10.1093/biomet/asv045>). Threshold selection methods, including Wadsworth (2016) <doi:10.1080/00401706.2014.998345>, and Northrop and Coleman (2014) <doi:10.1007/s10687-014-0183-z>. Multivariate extreme diagnostics. Estimation and likelihoods for univariate extremes, e.g., Coles (2001) <doi:10.1007/978-1-4471-3675-0>.
77
License: GPL-3

NAMESPACE

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ export(likmgp)
198198
export(maxstabtest)
199199
export(mvrnorm)
200200
export(pegp)
201+
export(penultimate)
201202
export(pextgp)
202203
export(pextgp.G)
203204
export(pgev)

R/asymcoef.R

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55
#' Semadeni's (2021) PhD thesis.
66
#' Two estimators are implemented: one based on empirical distributions, the second using empirical likelihood.
77
#' @details Let \code{U}, \code{V} be uniform random variables and define the partial extremal dependence coefficients
8-
#' \eqn{\varphi_{+}(u) = \Pr(V > U | U > u, V > u)},
9-
#' \eqn{\varphi_{-}(u) = \Pr(V < U | U > u, V > u)} and
10-
#' \eqn{\varphi_0(u) = \Pr(V = U | U > u, V > u)}
8+
#' \deqn{\varphi_{+}(u) = \Pr(V > U | U > u, V > u),},
9+
#' \deqn{\varphi_{-}(u) = \Pr(V < U | U > u, V > u),}
10+
#' \deqn{\varphi_0(u) = \Pr(V = U | U > u, V > u).}
1111
#' Define
1212
#' \deqn{ \varphi(u) = \frac{\varphi_{+} - \varphi_{-}}{\varphi_{+} + \varphi_{-}}}
13-
# and the coefficient of extremal asymmetry as \eqn{\varphi = \lim_{u \to 1} \varphi(u)}.
13+
#' and the coefficient of extremal asymmetry as \eqn{\varphi = \lim_{u \to 1} \varphi(u)}.
1414
#'
1515
#' The empirical likelihood estimator, derived for max-stable vectors with unit Frechet margins, is
1616
#' \deqn{\frac{\sum_i p_i I(w_i \leq 0.5) - 0.5}{0.5 - 2\sum_i p_i(0.5-w_i) I(w_i \leq 0.5)}}

R/extgp.R

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,24 @@ tstab.egp <- function(
755755
stop("Threshold vector not provided")
756756
}
757757
}
758-
if (model %in% c("egp1", "egp2", "egp3") & length(model) == 1) {
758+
model <- match.arg(
759+
model,
760+
choices = c(
761+
"pt-beta",
762+
"pt-gamma",
763+
"pt-power",
764+
"gj-tnorm",
765+
"gj-beta",
766+
"exptilt",
767+
"logist",
768+
"egp1",
769+
"egp2",
770+
"egp3"
771+
),
772+
several.ok = FALSE
773+
)
774+
775+
if (model %in% c("egp1", "egp2", "egp3")) {
759776
model <- switch(
760777
model,
761778
egp1 = "pt-beta",

R/kernel_exponential_thselect.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
#' \item{\code{k0}:} number of exceedances
1111
#' \item{\code{shape}:} Hill's shape estimate
1212
#' \item{\code{rho}:} second-order regular variation parameter estimate
13-
#' \item{\code{gof}:} goodness-of-fit statistic for the \"best\" threshold.
13+
#' \item{\code{gof}:} goodness-of-fit statistic for the chosen threshold.
1414
#' }
1515
#' @references Goegebeur , Y., Beirlant , J., and de Wet , T. (2008). Linking Pareto-Tail Kernel Goodness-of-fit Statistics with Tail Index at Optimal Threshold and Second Order Estimation. REVSTAT-Statistical Journal, 6(\bold{1}), 51–69. <doi:10.57805/revstat.v6i1.57>
1616
#' @export

R/lthill.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ tstab.lthill <- function(
243243

244244
#' Lower truncated Hill threshold selection
245245
#'
246-
#' Given a sample of positive data with Pareto tail, the algorithm computes the optimal number of order statistics that minimizes the variance of the average left truncated tail index estimator, and uses the relationship to the Hill estimator for the Hall class of distributions to derive the optimal number (minimizing the asymptotic mean squared error) of the Hill estimator. The default value for the second order regular variation index is taken to be \eqn{rho=-1}.
246+
#' Given a sample of positive data with Pareto tail, the algorithm computes the optimal number of order statistics that minimizes the variance of the average left truncated tail index estimator, and uses the relationship to the Hill estimator for the Hall class of distributions to derive the optimal number (minimizing the asymptotic mean squared error) of the Hill estimator. The default value for the second order regular variation index is taken to be \eqn{\rho=-1}.
247247
#' @param xdat [vector] positive vector of exceedances
248248
#' @param kmin [int] minimum number of exceedances
249249
#' @param kmax [int] maximum number of exceedances for the estimation of the shape parameter.

R/maxstabtest.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#' @param ties.method string indicating the method for \code{\link[base]{rank}}. Default to \code{"random"}.
1818
#' @param ... additional arguments for backward compatibility
1919
#' @param plot logical indicating whether a graph should be produced (default to \code{TRUE}).
20-
#' @return a Tukey probability-probability plot with 95% confidence intervals obtained using a nonparametric bootstrap
20+
#' @return a Tukey probability-probability plot with 95\% confidence intervals obtained using a nonparametric bootstrap
2121
#' @export
2222
#' @examples
2323
#' \dontrun{

R/mle.R

Lines changed: 73 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,7 +1003,7 @@ fit.rlarg <- function(
10031003
#' @export
10041004
plot.mev_gpd <- function(
10051005
x,
1006-
which = 1:2,
1006+
which = c("pp", "qq"),
10071007
main,
10081008
xlab = "Theoretical quantiles",
10091009
ylab = "Sample quantiles",
@@ -1015,12 +1015,17 @@ plot.mev_gpd <- function(
10151015
"Object \"x\" does not contain \"exceedances\", or else the latter is not a vector"
10161016
)
10171017
}
1018-
if (!is.numeric(which) || any(which < 1) || any(which > 2)) {
1019-
stop("\"which\" must be in 1:2")
1020-
}
10211018
show <- rep(FALSE, 2)
1022-
show[which] <- TRUE
1023-
if (!add) {
1019+
if (!is.numeric(which)) {
1020+
which <- match.arg(which)
1021+
show <- c("pp", "qq") %in% which
1022+
} else {
1023+
if (!isTRUE(all(which %in% 1:2))) {
1024+
stop("\"which\" must be in 1:2 if not a string")
1025+
}
1026+
show[which] <- TRUE
1027+
}
1028+
if (!isTRUE(add)) {
10241029
old.par <- par(no.readonly = TRUE)
10251030
if (sum(show) == 2) {
10261031
par(mfrow = c(1, 2), mar = c(5, 5, 4, 1))
@@ -1113,7 +1118,7 @@ plot.mev_gpd <- function(
11131118
#' @export
11141119
plot.mev_gpdbayes <- function(
11151120
x,
1116-
which = 1:2,
1121+
which = c("pp", "qq"),
11171122
main,
11181123
xlab = "Theoretical quantiles",
11191124
ylab = "Sample quantiles",
@@ -1125,12 +1130,17 @@ plot.mev_gpdbayes <- function(
11251130
"Object \"x\" does not contain \"exceedances\", or else the latter is not a vector"
11261131
)
11271132
}
1128-
if (!is.numeric(which) || any(which < 1) || any(which > 2)) {
1129-
stop("\"which\" must be in 1:2")
1130-
}
11311133
show <- rep(FALSE, 2)
1132-
show[which] <- TRUE
1133-
if (!add) {
1134+
if (!is.numeric(which)) {
1135+
which <- match.arg(which)
1136+
show <- c("pp", "qq") %in% which
1137+
} else {
1138+
if (!isTRUE(all(which %in% 1:2))) {
1139+
stop("\"which\" must be in 1:2 if not a string")
1140+
}
1141+
show[which] <- TRUE
1142+
}
1143+
if (!isTRUE(add)) {
11341144
old.par <- par(no.readonly = TRUE)
11351145
if (sum(show) == 2) {
11361146
par(mfrow = c(1, 2), mar = c(5, 5, 4, 1))
@@ -1229,27 +1239,35 @@ plot.mev_gpdbayes <- function(
12291239
#' @export
12301240
plot.mev_gev <- function(
12311241
x,
1232-
which = 1:2,
1242+
which = c("pp", "qq"),
12331243
main,
12341244
xlab = "Theoretical quantiles",
12351245
ylab = "Sample quantiles",
1246+
add = TRUE,
12361247
...
12371248
) {
12381249
if (!is.vector(x$xdat)) {
12391250
stop(
12401251
"Object \"x\" does not contain \"exceedances\", or else the latter is not a vector"
12411252
)
12421253
}
1243-
if (!is.numeric(which) || any(which < 1) || any(which > 2)) {
1244-
stop("\"which\" must be in 1:2")
1245-
}
12461254
show <- rep(FALSE, 2)
1247-
show[which] <- TRUE
1248-
old.par <- par(no.readonly = TRUE)
1249-
if (sum(show) == 2) {
1250-
par(mfrow = c(1, 2), mar = c(5, 5, 4, 1))
1255+
if (!is.numeric(which)) {
1256+
which <- match.arg(which)
1257+
show <- c("pp", "qq") %in% which
1258+
} else {
1259+
if (!isTRUE(all(which %in% 1:2))) {
1260+
stop("\"which\" must be in 1:2 if not a string")
1261+
}
1262+
show[which] <- TRUE
1263+
}
1264+
if (!isTRUE(add)) {
1265+
old.par <- par(no.readonly = TRUE)
1266+
if (sum(show) == 2) {
1267+
par(mfrow = c(1, 2), mar = c(5, 5, 4, 1))
1268+
}
1269+
on.exit(par(old.par))
12511270
}
1252-
on.exit(par(old.par))
12531271
if (missing(main)) {
12541272
main <- c("Probability-probability plot", "Quantile-quantile plot")
12551273
} else {
@@ -1329,10 +1347,11 @@ plot.mev_gev <- function(
13291347
#' @export
13301348
plot.mev_rlarg <- function(
13311349
x,
1332-
which = 1:2,
1350+
which = c("pp", "qq"),
13331351
main,
13341352
xlab = "Theoretical quantiles",
13351353
ylab = "Sample quantiles",
1354+
add = TRUE,
13361355
...
13371356
) {
13381357
if (!isTRUE(all.equal(x$param[3], 0, check.attributes = FALSE))) {
@@ -1348,16 +1367,24 @@ plot.mev_rlarg <- function(
13481367
dat <- sort(as.vector(c(ppdat[, 1], apply(ppdat, 1, diff))))
13491368
}
13501369
n <- length(dat)
1351-
if (!is.numeric(which) || any(which < 1) || any(which > 2)) {
1352-
stop("\"which\" must be in 1:2")
1353-
}
13541370
show <- rep(FALSE, 2)
1371+
if (!is.numeric(which)) {
1372+
which <- match.arg(which)
1373+
show <- c("pp", "qq") %in% which
1374+
} else {
1375+
if (!isTRUE(all(which %in% 1:2))) {
1376+
stop("\"which\" must be in 1:2 if not a string")
1377+
}
1378+
show[which] <- TRUE
1379+
}
13551380
show[which] <- TRUE
1356-
old.par <- par(no.readonly = TRUE)
1357-
if (sum(show) == 2) {
1358-
par(mfrow = c(1, 2), mar = c(5, 5, 4, 1))
1381+
if (!isTRUE(add)) {
1382+
old.par <- par(no.readonly = TRUE)
1383+
if (sum(show) == 2) {
1384+
par(mfrow = c(1, 2), mar = c(5, 5, 4, 1))
1385+
}
1386+
on.exit(par(old.par))
13591387
}
1360-
on.exit(par(old.par))
13611388
if (missing(main)) {
13621389
main <- c("Probability-probability plot", "Quantile-quantile plot")
13631390
} else {
@@ -1432,27 +1459,35 @@ plot.mev_rlarg <- function(
14321459
#' @export
14331460
plot.mev_pp <- function(
14341461
x,
1435-
which = 1:2,
1462+
which = c("pp", "qq"),
14361463
main = "Quantile-quantile plot",
14371464
xlab = "Theoretical quantiles",
14381465
ylab = "Sample quantiles",
1466+
add = TRUE,
14391467
...
14401468
) {
14411469
if (!is.vector(x$exceedances)) {
14421470
stop(
14431471
"Object \"x\" does not contain \"exceedances\", or else the latter is not a vector"
14441472
)
14451473
}
1446-
if (!is.numeric(which) || any(which < 1) || any(which > 2)) {
1447-
stop("\"which\" must be in 1:2")
1448-
}
14491474
show <- rep(FALSE, 2)
1450-
show[which] <- TRUE
1451-
old.par <- par(no.readonly = TRUE)
1452-
if (sum(show) == 2) {
1453-
par(mfrow = c(1, 2), mar = c(5, 5, 4, 1))
1475+
if (!is.numeric(which)) {
1476+
which <- match.arg(which)
1477+
show <- c("pp", "qq") %in% which
1478+
} else {
1479+
if (!isTRUE(all(which %in% 1:2))) {
1480+
stop("\"which\" must be in 1:2 if not a string")
1481+
}
1482+
show[which] <- TRUE
1483+
}
1484+
if (!isTRUE(add)) {
1485+
old.par <- par(no.readonly = TRUE)
1486+
if (sum(show) == 2) {
1487+
par(mfrow = c(1, 2), mar = c(5, 5, 4, 1))
1488+
}
1489+
on.exit(par(old.par))
14541490
}
1455-
on.exit(par(old.par))
14561491
if (missing(main)) {
14571492
main <- c("Probability-probability plot", "Quantile-quantile plot")
14581493
} else {

R/mrl.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ automrl <- function(
204204

205205
#' Mean residual life plot
206206
#'
207-
#' Computes mean of sample exceedances over a range of thresholds or for a prespecified number of largest order statistics, and returns a plot with 95% Wald-based confidence intervals as a function of either the threshold or the number of exceedances. The main purpose is the plotting method, which generates the so-called mean residual life plot. The latter should be approximately linear over the threshold for a generalized Pareto distribution
207+
#' Computes mean of sample exceedances over a range of thresholds or for a pre-specified number of largest order statistics, and returns a plot with 95\% Wald-based confidence intervals as a function of either the threshold or the number of exceedances. The main purpose is the plotting method, which generates the so-called mean residual life plot. The latter should be approximately linear over the threshold for a generalized Pareto distribution
208208
#'
209209
#' @references Davison, A.C. and R.L. Smith (1990). Models for Exceedances over High Thresholds (with discussion), \emph{Journal of the Royal Statistical Society. Series B (Methodological)}, \bold{52}(3), 393--442.
210210
#' @export

0 commit comments

Comments
 (0)