Title: | Extremal Dependence Models |
---|---|
Description: | A set of procedures for parametric and non-parametric modelling of the dependence structure of multivariate extreme-values is provided. The statistical inference is performed with non-parametric estimators, likelihood-based estimators and Bayesian techniques. It adapts the methodologies of Beranger and Padoan (2015) <doi:10.48550/arXiv.1508.05561>, Marcon et al. (2016) <doi:10.1214/16-EJS1162>, Marcon et al. (2017) <doi:10.1002/sta4.145>, Marcon et al. (2017) <doi:10.1016/j.jspi.2016.10.004> and Beranger et al. (2021) <doi:10.1007/s10687-019-00364-0>. This package also allows for the modelling of spatial extremes using flexible max-stable processes. It provides simulation algorithms and fitting procedures relying on the Stephenson-Tawn likelihood as per Beranger at al. (2021) <doi:10.1007/s10687-020-00376-1>. |
Authors: | Boris Beranger [aut], Simone Padoan [cre, aut], Giulia Marcon [aut], Steven G. Johnson [ctb] (Author of included cubature fragments), Rudolf Schuerer [ctb] (Author of included cubature fragments), Brian Gough [ctb] (Author of included cubature fragments), Alec G. Stephenson [ctb], Anne Sabourin [ctb] (Author of included BMAmevt fragments) |
Maintainer: | Simone Padoan <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.0.4-2 |
Built: | 2024-11-06 06:40:08 UTC |
Source: | CRAN |
Empirical estimation to the Pickands dependence function, the angular density, the angular measure and random generation of samples from the estimated angular density.
angular(data, model, n, dep, asy, alpha, beta, df, seed, k, nsim, plot=TRUE, nw=100)
angular(data, model, n, dep, asy, alpha, beta, df, seed, k, nsim, plot=TRUE, nw=100)
data |
The dataset in vector form |
model |
The specified model; a character string. Must be either |
n |
The number of random generations from the |
dep |
The dependence parameter for the |
asy |
A vector of length two, containing the two asymmetry parameters for the asymmetric logistic ( |
alpha , beta
|
Alpha and beta parameters for the bilogistic, negative logistic, Coles-Tawn and asymmetric mixed models. |
df |
The degree of freedom for the extremal-t model. |
seed |
The seed for the data generation. Required if |
k |
The polynomial order. |
nsim |
The number of generations from the estimated angular density. |
plot |
If |
nw |
The number of points at which the estimated functions are evaluated |
See Marcon et al. (2017).
Returns a list which contains model
, n
, dep
, data
, Aest
the estimated pickands dependence function, hest
the estimated angular density, Hest
the estimated angular measure, p0
and p1
the point masses at the edge of the simplex, wsim
the simulated sample from the angular density and Atrue
and htrue
the true Pickand dependence function and angular density (if model
is specified).
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com; Giulia Marcon, [email protected]
Marcon, G., Naveau, P. and Padoan, S. A. (2017). A semi-parametric stochastic generator for bivariate extreme events, Stat 6(1), 184–201.
################################################ # The following examples provide the left panels # of Figure 1, 2 & 3 of Marcon et al. (2017). ################################################ ## Figure 1 - symmetric logistic # Strong dependence a <- angular(model='log', n=50, dep=0.3, seed=4321, k=20, nsim=10000) # Mild dependence b <- angular(model='log', n=50, dep=0.6, seed=212, k=10, nsim=10000) # Weak dependence c <- angular(model='log', n=50, dep=0.9, seed=4334, k=6, nsim=10000) ## Figure 2 - Asymmetric logistic # Strong dependence d <- angular(model='alog', n=25, dep=0.3, asy=c(.3,.8), seed=43121465, k=20, nsim=10000) # Mild dependence e <- angular(model='alog', n=25, dep=0.6, asy=c(.3,.8), seed=1890, k=10, nsim=10000) # Weak dependence f <- angular(model='alog', n=25, dep=0.9, asy=c(.3,.8), seed=2043, k=5, nsim=10000)
################################################ # The following examples provide the left panels # of Figure 1, 2 & 3 of Marcon et al. (2017). ################################################ ## Figure 1 - symmetric logistic # Strong dependence a <- angular(model='log', n=50, dep=0.3, seed=4321, k=20, nsim=10000) # Mild dependence b <- angular(model='log', n=50, dep=0.6, seed=212, k=10, nsim=10000) # Weak dependence c <- angular(model='log', n=50, dep=0.9, seed=4334, k=6, nsim=10000) ## Figure 2 - Asymmetric logistic # Strong dependence d <- angular(model='alog', n=25, dep=0.3, asy=c(.3,.8), seed=43121465, k=20, nsim=10000) # Mild dependence e <- angular(model='alog', n=25, dep=0.6, asy=c(.3,.8), seed=1890, k=10, nsim=10000) # Weak dependence f <- angular(model='alog', n=25, dep=0.9, asy=c(.3,.8), seed=2043, k=5, nsim=10000)
Estimates the Pickands dependence function corresponding to multivariate data on the basis of a Bernstein polynomials approximation.
beed(data, x, d = 3, est = c("ht","cfg","md","pick"), margin = c("emp","est","exp","frechet","gumbel"), k = 13, y = NULL, beta = NULL, plot = FALSE)
beed(data, x, d = 3, est = c("ht","cfg","md","pick"), margin = c("emp","est","exp","frechet","gumbel"), k = 13, y = NULL, beta = NULL, plot = FALSE)
data |
|
x |
|
d |
positive integer greater than or equal to two indicating the number of variables ( |
est |
string, indicating the estimation method ( |
margin |
string, denoting the type marginal distributions ( |
k |
postive integer, indicating the order of Bernstein
polynomials ( |
y |
numeric vector (of size |
beta |
vector of polynomial coefficients (see Details). |
plot |
logical; if |
The routine returns an estimate of the Pickands dependence function using the Bernstein polynomials approximation
proposed in Marcon et al. (2017).
The method is based on a preliminary empirical estimate of the Pickands dependence function.
If you do not provide such an estimate, this is computed by the routine. In this case, you can select one of the empirical methods
available. est = 'ht'
refers to the Hall-Tajvidi estimator (Hall and Tajvidi 2000).
With est = 'cfg'
the method proposed by Caperaa et al. (1997) is considered. Note that in the multivariate case the adjusted version of Gudendorf and Segers (2011) is used. Finally, with est = 'md'
the estimate is based on the madogram defined in Marcon et al. (2017).
Each row of the design matrix
x
is a point in the unit d
-dimensional simplex,
With this "regularization"" method, the final estimate satisfies the neccessary conditions in order to be a Pickands dependence function.
The estimates are obtained by solving an optimization quadratic problem subject to the constraints. The latter are represented
by the following conditions:
(convexity).
The order of polynomial k
controls the smoothness of the estimate. The higher k
is, the smoother the final estimate is.
Higher values are better with strong dependence (e. g. k = 23
), whereas small values (e.g. k = 6
or k = 10
) are enough with mild or weak dependence.
An empirical transformation of the marginals is performed when margin="emp"
. A max-likelihood fitting of the GEV distributions is implemented when margin="est"
. Otherwise it refers to marginal parametric GEV theorethical distributions (margin = "exp", "frechet", "gumbel"
).
beta |
vector of polynomial coefficients |
A |
numeric vector of the estimated Pickands dependence function |
Anonconvex |
preliminary non-convex function |
extind |
extremal index |
The number of coefficients depends on both the order of polynomial k
and the dimension d
. The number of parameters is explained in Marcon et al. (2017).
The size of the vector beta
must be compatible with the polynomial order k
chosen.
With the estimated polynomial coefficients, the extremal coefficient, i.e. is computed.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com; Giulia Marcon, [email protected]
Marcon, G., Padoan, S.A., Naveau, P., Muliere, P. and Segers, J. (2017) Multivariate Nonparametric Estimation of the Pickands Dependence Function using Bernstein Polynomials. Journal of Statistical Planning and Inference, 183, 1-17.
x <- simplex(2) data <- evd::rbvevd(50, dep = 0.4, model = "log", mar1 = c(1,1,1)) Amd <- beed(data, x, 2, "md", "emp", 20, plot=TRUE) Acfg <- beed(data, x, 2, "cfg", "emp", 20) Aht <- beed(data, x, 2, "ht", "emp", 20) lines(x[,1], Aht$A, lty = 1, col = 3) lines(x[,1], Acfg$A, lty = 1, col = 2) ################################## # Trivariate case ################################## x <- simplex(3) data <- evd::rmvevd(50, dep = 0.8, model = "log", d = 3, mar = c(1,1,1)) op <- par(mfrow=c(1,3)) Amd <- beed(data, x, 3, "md", "emp", 18, plot=TRUE) Acfg <- beed(data, x, 3, "cfg", "emp", 18, plot=TRUE) Aht <- beed(data, x, 3, "ht", "emp", 18, plot=TRUE) par(op)
x <- simplex(2) data <- evd::rbvevd(50, dep = 0.4, model = "log", mar1 = c(1,1,1)) Amd <- beed(data, x, 2, "md", "emp", 20, plot=TRUE) Acfg <- beed(data, x, 2, "cfg", "emp", 20) Aht <- beed(data, x, 2, "ht", "emp", 20) lines(x[,1], Aht$A, lty = 1, col = 3) lines(x[,1], Acfg$A, lty = 1, col = 2) ################################## # Trivariate case ################################## x <- simplex(3) data <- evd::rmvevd(50, dep = 0.8, model = "log", d = 3, mar = c(1,1,1)) op <- par(mfrow=c(1,3)) Amd <- beed(data, x, 3, "md", "emp", 18, plot=TRUE) Acfg <- beed(data, x, 3, "cfg", "emp", 18, plot=TRUE) Aht <- beed(data, x, 3, "ht", "emp", 18, plot=TRUE) par(op)
Computes nboot
estimates of the Pickands dependence function for multivariate data (using the Bernstein polynomials approximation method) on the basis of the bootstrap resampling of the data.
beed.boot(data, x, d = 3, est = c("ht","md","cfg","pick"), margin=c("emp", "est", "exp", "frechet", "gumbel"), k = 13, nboot = 500, y = NULL, print = FALSE)
beed.boot(data, x, d = 3, est = c("ht","md","cfg","pick"), margin=c("emp", "est", "exp", "frechet", "gumbel"), k = 13, nboot = 500, y = NULL, print = FALSE)
data |
|
x |
|
d |
postive integer (greater than or equal to two) indicating the number of variables ( |
est |
string denoting the preliminary estimation method (see Details). |
margin |
string denoting the type marginal distributions (see Details). |
k |
postive integer denoting the order of the Bernstein polynomial ( |
nboot |
postive integer indicating the number of bootstrap replicates ( |
y |
numeric vector (of size |
print |
logical; |
Standard bootstrap is performed, in particular estimates of the Pickands dependence function are provided for each data resampling.
Most of the settings are the same as in the function beed
.
An empirical transformation of the marginals is performed when margin="emp"
. A max-likelihood fitting of the GEV distributions is implemented when margin="est"
. Otherwise it refers to marginal parametric GEV theorethical distributions (margin = "exp", "frechet", "gumbel"
).
A |
numeric vector of the estimated Pickands dependence function. |
bootA |
matrix with |
beta |
matrix of estimated polynomial coefficients. Each column corresponds to a data resampling. |
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com; Giulia Marcon, [email protected]
Marcon, G., Padoan, S.A., Naveau, P., Muliere, P. and Segers, J. (2017) Multivariate Nonparametric Estimation of the Pickands Dependence Function using Bernstein Polynomials. Journal of Statistical Planning and Inference, 183, 1-17.
x <- simplex(2) data <- evd::rbvevd(50, dep = 0.4, model = "log", mar1 = c(1,1,1)) boot <- beed.boot(data, x, 2, "md", "emp", 20, 500)
x <- simplex(2) data <- evd::rbvevd(50, dep = 0.4, model = "log", mar1 = c(1,1,1)) boot <- beed.boot(data, x, 2, "md", "emp", 20, 500)
Computes nonparametric bootstrap confidence bands for the Pickands dependence function.
beed.confband(data, x, d = 3, est = c("ht","md","cfg","pick"), margin=c("emp", "est", "exp", "frechet", "gumbel"), k = 13, nboot = 500, y = NULL, conf = 0.95, plot = FALSE, print = FALSE)
beed.confband(data, x, d = 3, est = c("ht","md","cfg","pick"), margin=c("emp", "est", "exp", "frechet", "gumbel"), k = 13, nboot = 500, y = NULL, conf = 0.95, plot = FALSE, print = FALSE)
data |
|
x |
|
d |
postive integer (greater than or equal to two) indicating the number of variables ( |
est |
string denoting the estimation method (see Details). |
margin |
string denoting the type marginal distributions (see Details). |
k |
postive integer denoting the order of the Bernstein polynomial ( |
nboot |
postive integer indicating the number of bootstrap replicates. |
y |
numeric vector (of size |
conf |
real value in |
plot |
logical; |
print |
logical; |
Two methods for computing bootstrap point-wise and simultaneous confidence bands for the Pickands dependence function are used.
The first method derives the confidence bands computing the point-wise and
quantiles of the bootstrap sample distribution of the Pickands dependence Bernstein based estimator.
The second method derives the confidence bands, first computing the point-wise and
quantiles of the bootstrap sample distribution of polynomial coefficient estimators, and then the Pickands dependence is computed using the Bernstein polynomial representation. See Marcon et al. (2017) for details.
Most of the settings are the same as in the function beed
.
A |
numeric vector of the Pickands dependence function estimated. |
bootA |
matrix with |
A.up.beta/A.low.beta |
vectors of upper and lower bands of the Pickands dependence function obtained using the bootstrap sampling distribution of the polynomial coefficients estimator. |
A.up.pointwise/A.low.pointwise |
vectors of upper and lower bands of the Pickands dependence function obtained using the bootstrap sampling distribution of the Pickands dependence function estimator. |
up.beta/low.beta |
vectors of upper and lower bounds of the bootstrap sampling distribution of the polynomial coefficients estimator. |
This routine relies on the bootstrap routine (see beed.boot
).
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com; Giulia Marcon, [email protected]
Marcon, G., Padoan, S.A., Naveau, P., Muliere, P. and Segers, J. (2017) Multivariate Nonparametric Estimation of the Pickands Dependence Function using Bernstein Polynomials. Journal of Statistical Planning and Inference, 183, 1-17.
x <- simplex(2) data <- evd::rbvevd(50, dep = 0.4, model = "log", mar1 = c(1,1,1)) # Note you should consider 500 bootstrap replications. # In order to obtain fastest results we used 50! cb <- beed.confband(data, x, 2, "md", "emp", 20, 50, plot=TRUE)
x <- simplex(2) data <- evd::rbvevd(50, dep = 0.4, model = "log", mar1 = c(1,1,1)) # Note you should consider 500 bootstrap replications. # In order to obtain fastest results we used 50! cb <- beed.confband(data, x, 2, "md", "emp", 20, 50, plot=TRUE)
Density function, distribution function for the univariate extended skew-normal (ESN) distribution.
desn(x, location=0, scale=1, shape=0, extended=0) pesn(x, location=0, scale=1, shape=0, extended=0)
desn(x, location=0, scale=1, shape=0, extended=0) pesn(x, location=0, scale=1, shape=0, extended=0)
x |
quantile. |
location |
location parameter. |
scale |
scale parameter; must be positive. |
shape |
skewness parameter. |
extended |
extension parameter. |
density (desn
), probability (pesn
) from the extended skew-normal distribution with given
location
, scale
, shape
and extended
parameters or from the skew-normal if extended=0
.
If shape=0
and extended=0
then the normal distribution is recovered.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
Azzalini, A. (1985). A class of distributions which includes the normal ones. Scand. J. Statist. 12, 171-178.
Azzalini, A. with the collaboration of Capitanio, A. (2014). The Skew-Normal and Related Families. Cambridge University Press, IMS Monographs series.
dens1 <- desn(x=1, shape=3, extended=2) dens2 <- desn(x=1, shape=3) dens3 <- desn(x=1) dens4 <- dnorm(x=1) prob1 <- pesn(x=1, shape=3, extended=2) prob2 <- pesn(x=1, shape=3) prob3 <- pesn(x=1) prob4 <- pnorm(q=1)
dens1 <- desn(x=1, shape=3, extended=2) dens2 <- desn(x=1, shape=3) dens3 <- desn(x=1) dens4 <- dnorm(x=1) prob1 <- pesn(x=1, shape=3, extended=2) prob2 <- pesn(x=1, shape=3) prob3 <- pesn(x=1) prob4 <- pnorm(q=1)
Density function, distribution function for the univariate extended skew-t (EST) distribution.
dest(x, location=0, scale=1, shape=0, extended=0, df=Inf) pest(x, location=0, scale=1, shape=0, extended=0, df=Inf)
dest(x, location=0, scale=1, shape=0, extended=0, df=Inf) pest(x, location=0, scale=1, shape=0, extended=0, df=Inf)
x |
quantile. |
location |
location parameter. |
scale |
scale parameter; must be positive. |
shape |
skewness parameter. |
extended |
extension parameter. |
df |
a single positive value representing the degrees of freedom;
it can be non-integer. Default value is |
density (dest
), probability (pest
) from the extended skew-t distribution with given
location
, scale
, shape
, extended
and df
parameters or from the skew-t if extended=0
.
If shape=0
and extended=0
then the t distribution is recovered.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
Azzalini, A. and Capitanio, A. (2003). Distributions generated by perturbation of symmetry with emphasis on a multivariate skew-t distribution. J.Roy. Statist. Soc. B 65, 367–389.
Azzalini, A. with the collaboration of Capitanio, A. (2014). The Skew-normal and Related Families. Cambridge University Press, IMS Monographs series.
dens1 <- dest(x=1, shape=3, extended=2, df=1) dens2 <- dest(x=1, shape=3, df=1) dens3 <- dest(x=1, df=1) dens4 <- dt(x=1, df=1) prob1 <- pest(x=1, shape=3, extended=2, df=1) prob2 <- pest(x=1, shape=3, df=1) prob3 <- pest(x=1, df=1) prob4 <- pt(q=1, df=1)
dens1 <- dest(x=1, shape=3, extended=2, df=1) dens2 <- dest(x=1, shape=3, df=1) dens3 <- dest(x=1, df=1) dens4 <- dt(x=1, df=1) prob1 <- pest(x=1, shape=3, extended=2, df=1) prob2 <- pest(x=1, shape=3, df=1) prob3 <- pest(x=1, df=1) prob4 <- pt(q=1, df=1)
This function calculates the density of parametric multivariate extreme distributions and corresponding angular density, or the non-parametric angular density represented through Bernstein polynomials.
dExtDep(x, method="Parametric", model, par, angular=TRUE, log=FALSE, c=NULL, vectorial=TRUE, mixture=FALSE)
dExtDep(x, method="Parametric", model, par, angular=TRUE, log=FALSE, c=NULL, vectorial=TRUE, mixture=FALSE)
x |
A vector or a matrix. The value at which the density is evaluated. |
method |
A character string taking value |
model |
A string with the name of the model: |
par |
A vector representing the parameters of the (parametric or non-parametric) model. |
angular |
A logical value specifying if the angular density is computed. |
log |
A logical value specifying if the log density is computed. |
c |
A real value in |
vectorial |
A logical value; if |
mixture |
A logical value specifying if the Bernstein polynomial representation of distribution should be expressed as a mixture. If |
Note that when method="Parametric"
and angular=FALSE
, the density is only available in 2 dimensions.
When method="Parametric"
and angular=TRUE
, the models "AL"
, "ET"
and "EST"
are limited to 3 dimensions. This is because of the existence of mass on the subspaces on the simplex (and therefore the need to specify c
).
For the parametric models, the appropriate length of the parameter vector can be obtained from the dim_ExtDep
function and are summarized as follows.
When model="HR"
, the parameter vector is of length choose(dim,2)
.
When model="PB"
or model="Extremalt"
, the parameter vector is of length choose(dim,2) + 1
.
When model="EST"
, the parameter vector is of length choose(dim,2) + dim + 1
.
When model="TD"
, the parameter vector is of length dim
.
When model="AL"
, the parameter vector is of length 2^(dim-1)*(dim+2) - (2*dim+1)
.
If x
is a matrix and vectorial=TRUE
, a vector of length nrow(x)
, otherwise a scalar.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
Beranger, B. and Padoan, S. A. (2015). Extreme dependence models, chapater of the book Extreme Value Modeling and Risk Analysis: Methods and Applications, Chapman Hall/CRC.
Beranger, B., Padoan, S. A. and Sisson, S. A. (2017). Models for extremal dependence derived from skew-symmetric families. Scandinavian Journal of Statistics, 44(1), 21-45.
Coles, S. G., and Tawn, J. A. (1991), Modelling Extreme Multivariate Events, Journal of the Royal Statistical Society, Series B (Methodological), 53, 377–392.
Cooley, D.,Davis, R. A., and Naveau, P. (2010). The pairwise beta distribution: a flexible parametric multivariate model for extremes. Journal of Multivariate Analysis, 101, 2103–2117.
Engelke, S., Malinowski, A., Kabluchko, Z., and Schlather, M. (2015), Estimation of Husler-Reiss distributions and Brown-Resnick processes, Journal of the Royal Statistical Society, Series B (Methodological), 77, 239–265.
Husler, J. and Reiss, R.-D. (1989), Maxima of normal random vectors: between independence and complete dependence, Statistics and Probability Letters, 7, 283–286.
Marcon, G., Padoan, S.A., Naveau, P., Muliere, P. and Segers, J. (2017) Multivariate Nonparametric Estimation of the Pickands Dependence Function using Bernstein Polynomials. Journal of Statistical Planning and Inference, 183, 1-17.
Nikoloulopoulos, A. K., Joe, H., and Li, H. (2009) Extreme value properties of t copulas. Extremes, 12, 129–148.
Opitz, T. (2013) Extremal t processes: Elliptical domain of attraction and a spectral representation. Jounal of Multivariate Analysis, 122, 409–413.
Tawn, J. A. (1990), Modelling Multivariate Extreme Value Distributions, Biometrika, 77, 245–253.
pExtDep
, rExtDep
, fExtDep
, fExtDep.np
# Example of PB on the 4-dimensional simplex dExtDep(x=rbind(c(0.1,0.3,0.3,0.3),c(0.1,0.2,0.3,0.4)), method="Parametric", model="PB", par=c(2,2,2,1,0.5,3,4), log=FALSE) # Example of EST in 2 dimensions dExtDep(x=c(1.2,2.3), method="Parametric", model="EST", par=c(0.6,1,2,3), angular=FALSE, log=TRUE) # Example of non-parametric angular density beta <- c(1.0000000, 0.8714286, 0.7671560, 0.7569398, 0.7771908, 0.8031573, 0.8857143, 1.0000000) dExtDep(x=rbind(c(0.1,0.9),c(0.2,0.8)), method="NonParametric", par=beta)
# Example of PB on the 4-dimensional simplex dExtDep(x=rbind(c(0.1,0.3,0.3,0.3),c(0.1,0.2,0.3,0.4)), method="Parametric", model="PB", par=c(2,2,2,1,0.5,3,4), log=FALSE) # Example of EST in 2 dimensions dExtDep(x=c(1.2,2.3), method="Parametric", model="EST", par=c(0.6,1,2,3), angular=FALSE, log=TRUE) # Example of non-parametric angular density beta <- c(1.0000000, 0.8714286, 0.7671560, 0.7569398, 0.7771908, 0.8031573, 0.8857143, 1.0000000) dExtDep(x=rbind(c(0.1,0.9),c(0.2,0.8)), method="NonParametric", par=beta)
Density, distribution and quantile function for the Generalized Extreme Value (GEV) distribution.
dGEV(x, loc, scale, shape, log=FALSE) pGEV(q, loc, scale, shape, lower.tail=TRUE) qGEV(p, loc, scale, shape)
dGEV(x, loc, scale, shape, log=FALSE) pGEV(q, loc, scale, shape, lower.tail=TRUE) qGEV(p, loc, scale, shape)
x , q
|
vector of quantiles. |
p |
vector of probabilities. |
loc |
vector of locations. |
scale |
vector of scales. |
shape |
vector of shapes. |
log |
A logical value; if |
lower.tail |
A logical value; if |
The GEV distribution has density
density (dGEV
), distribution function (pGEV
) and quantile function (qGEV
) from the Generalized Extreme Value distirbution with given
location
, scale
and shape
.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
# Densities dGEV(x=1, loc=1, scale=1, shape=1) dGEV(x=c(0.2, 0.5), loc=1, scale=1, shape=c(0,0.3)) # Probabilities pGEV(q=1, loc=1, scale=1, shape=1, lower.tail=FALSE) pGEV(q=c(0.2, 0.5), loc=1, scale=1, shape=c(0,0.3)) # Quantiles qGEV(p=0.5, loc=1, scale=1, shape=1) qGEV(p=c(0.2, 0.5), loc=1, scale=1, shape=c(0,0.3))
# Densities dGEV(x=1, loc=1, scale=1, shape=1) dGEV(x=c(0.2, 0.5), loc=1, scale=1, shape=c(0,0.3)) # Probabilities pGEV(q=1, loc=1, scale=1, shape=1, lower.tail=FALSE) pGEV(q=c(0.2, 0.5), loc=1, scale=1, shape=c(0,0.3)) # Quantiles qGEV(p=0.5, loc=1, scale=1, shape=1) qGEV(p=c(0.2, 0.5), loc=1, scale=1, shape=c(0,0.3))
This function displays traceplots of the scaling parameter from the proposal distribution of the adaptive MCMC scheme and the associated acceptance probability.
diagnostics(mcmc)
diagnostics(mcmc)
mcmc |
An output of the |
When mcmc
is the output of fGEV
then this corresponds to a marginal estimation and therefore diagnostics
will display in a first plot the value of the scaling parameter in the multivariate normal proposal which directly affects the acceptance rate of the proposal parameter values that are displayed in the second plot.
When mcmc
is the output of fExtDep.np
, then this corresponds to an estimation of the dependence structure following the procedure given in Algorithm 1 of Beranger et al. (2021). If the margins are jointly estimated with the dependence (step 1 and 2 of the algorithm) then diagnostics
provides trace plots of the corresponding scaling parameters () and acceptance probabilities. For the dependence structure (step 3 of the algorithm), a trace plot of the polynomial order
is given with the associated acceptance probability.
a graph of traceplots of the scaling parameter from the proposal distribution of the adaptive MCMC scheme and the associated acceptance probability.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com; Giulia Marcon, [email protected]
Beranger, B., Padoan, S. A. and Sisson, S. A. (2021). Estimation and uncertainty quantification for extreme quantile regions. Extremes, 24, 349-375.
################################################## ### Example - Pollution levels in Milan, Italy ### ################################################## ## Not run: ### Here we will only model the dependence structure data(MilanPollution) data <- Milan.winter[,c("NO2","SO2")] data <- as.matrix(data[complete.cases(data),]) # Thereshold u <- apply(data, 2, function(x) quantile(x, prob=0.9, type=3)) # Hyperparameters hyperparam <- list(mu.nbinom = 6, var.nbinom = 8, a.unif=0, b.unif=0.2) ### Standardise data to univariate Frechet margins f1 <- fGEV(data=data[,1], method="Bayesian", sig0 = 0.1, nsim = 5e+4) diagnostics(f1) burn1 <- 1:30000 gev.pars1 <- apply(f1$param_post[-burn1,],2,mean) sdata1 <- trans2UFrechet(data=data[,1], pars=gev.pars1, type="GEV") f2 <- fGEV(data=data[,2], method="Bayesian", sig0 = 0.1, nsim = 5e+4) diagnostics(f2) burn2 <- 1:30000 gev.pars2 <- apply(f2$param_post[-burn2,],2,mean) sdata2 <- trans2UFrechet(data=data[,2], pars=gev.pars2, type="GEV") sdata <- cbind(sdata1,sdata2) ### Bayesian estimation using Bernstein polynomials pollut1 <- fExtDep.np(method="Bayesian", data=sdata, u=TRUE, mar.fit=FALSE, k0=5, hyperparam = hyperparam, nsim=5e+4) diagnostics(pollut1) ## End(Not run)
################################################## ### Example - Pollution levels in Milan, Italy ### ################################################## ## Not run: ### Here we will only model the dependence structure data(MilanPollution) data <- Milan.winter[,c("NO2","SO2")] data <- as.matrix(data[complete.cases(data),]) # Thereshold u <- apply(data, 2, function(x) quantile(x, prob=0.9, type=3)) # Hyperparameters hyperparam <- list(mu.nbinom = 6, var.nbinom = 8, a.unif=0, b.unif=0.2) ### Standardise data to univariate Frechet margins f1 <- fGEV(data=data[,1], method="Bayesian", sig0 = 0.1, nsim = 5e+4) diagnostics(f1) burn1 <- 1:30000 gev.pars1 <- apply(f1$param_post[-burn1,],2,mean) sdata1 <- trans2UFrechet(data=data[,1], pars=gev.pars1, type="GEV") f2 <- fGEV(data=data[,2], method="Bayesian", sig0 = 0.1, nsim = 5e+4) diagnostics(f2) burn2 <- 1:30000 gev.pars2 <- apply(f2$param_post[-burn2,],2,mean) sdata2 <- trans2UFrechet(data=data[,2], pars=gev.pars2, type="GEV") sdata <- cbind(sdata1,sdata2) ### Bayesian estimation using Bernstein polynomials pollut1 <- fExtDep.np(method="Bayesian", data=sdata, u=TRUE, mar.fit=FALSE, k0=5, hyperparam = hyperparam, nsim=5e+4) diagnostics(pollut1) ## End(Not run)
This function calculates the dimensions of an extremal dependence model for a given set of parameters, the dimension of the parameter vector for a given dimension and verifies the adequacy between model dimension and length of parameter vector when both are provided.
dim_ExtDep(model, par=NULL, dim=NULL)
dim_ExtDep(model, par=NULL, dim=NULL)
model |
A string with the name of the model: |
par |
A vector representing the parameters of the model. |
dim |
An integer representing the dimension of the model. |
One of par
or dim
need to be provided.
If par
is provided, the dimension of the model is calculated.
If dim
is provided, the length of the parameter vector is calculated.
If both par
and dim
are provided, the adequacy between the dimension of the model and the length of the parameter vector is checked.
For model="HR"
, the parameter vector is of length choose(dim,2)
.
For model="PB"
or model="Extremalt"
, the parameter vector is of length choose(dim,2) + 1
.
For model="EST"
, the parameter vector is of length choose(dim,2) + dim + 1
.
For model="TD"
, the parameter vector is of length dim
.
For model="AL"
, the parameter vector is of length 2^(dim-1)*(dim+2) - (2*dim+1)
.
If par
is not provided and dim
is provided: returns an integer indicating the length of the parameter vector.
If par
is provided and dim
is not provided: returns an integer indicating the dimension of the model.
If par
and dim
are provided: returns a TRUE/FALSE
statement indicating whether the length of the parameter and the dimension match.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
dim_ExtDep(model="EST", dim=3) dim_ExtDep(model="AL", dim=3) dim_ExtDep(model="PB", par=rep(0.5,choose(4,2)+1) ) dim_ExtDep(model="TD", par=rep(1,5) ) dim_ExtDep(model="EST", dim=2, par=c(0.5,1,1,1) ) dim_ExtDep(model="PB", dim=4, par=rep(0.5,choose(4,2)+1) )
dim_ExtDep(model="EST", dim=3) dim_ExtDep(model="AL", dim=3) dim_ExtDep(model="PB", par=rep(0.5,choose(4,2)+1) ) dim_ExtDep(model="TD", par=rep(1,5) ) dim_ExtDep(model="EST", dim=2, par=c(0.5,1,1,1) ) dim_ExtDep(model="PB", dim=4, par=rep(0.5,choose(4,2)+1) )
Density function, distribution function for the bivariate and trivariate extended skew-normal (ESN) distribution.
dmesn(x=c(0,0), location=rep(0, length(x)), scale=diag(length(x)), shape=rep(0,length(x)), extended=0) pmesn(x=c(0,0), location=rep(0, length(x)), scale=diag(length(x)), shape=rep(0,length(x)), extended=0)
dmesn(x=c(0,0), location=rep(0, length(x)), scale=diag(length(x)), shape=rep(0,length(x)), extended=0) pmesn(x=c(0,0), location=rep(0, length(x)), scale=diag(length(x)), shape=rep(0,length(x)), extended=0)
x |
quantile vector of length |
location |
a numeric location vector of length |
scale |
a symmetric positive-definite scale matrix of dimension |
shape |
a numeric skewness vector of length |
extended |
a single value extension parameter. |
density (dmesn
), probability (pmesn
) from the bivariate or trivariate extended skew-normal distribution with given
location
, scale
, shape
and extended
parameters or from the skew-normal distribution if extended=0
.
If shape=0
and extended=0
then the normal distribution is recovered.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
Azzalini, A. and Capitanio, A. (1999). Statistical applications of the multivariate skew normal distribution. J.Roy.Statist.Soc. B 61, 579–602.
Azzalini, A. with the collaboration of Capitanio, A. (2014). The Skew-Normal and Related Families. Cambridge University Press, IMS Monographs series.
Azzalini, A. and Dalla Valle, A. (1996). The multivariate skew-normal distribution. Biometrika 83, 715–726.
sigma1 <- matrix(c(2,1.5,1.5,3),ncol=2) sigma2 <- matrix(c(2,1.5,1.8,1.5,3,2.2,1.8,2.2,3.5),ncol=3) shape1 <- c(1,2) shape2 <- c(1,2,1.5) dens1 <- dmesn(x=c(1,1), scale=sigma1, shape=shape1, extended=2) dens2 <- dmesn(x=c(1,1), scale=sigma1) dens3 <- dmesn(x=c(1,1,1), scale=sigma2, shape=shape2, extended=2) dens4 <- dmesn(x=c(1,1,1), scale=sigma2) prob1 <- pmesn(x=c(1,1), scale=sigma1, shape=shape1, extended=2) prob2 <- pmesn(x=c(1,1), scale=sigma1) prob3 <- pmesn(x=c(1,1,1), scale=sigma2, shape=shape2, extended=2) prob4 <- pmesn(x=c(1,1,1), scale=sigma2)
sigma1 <- matrix(c(2,1.5,1.5,3),ncol=2) sigma2 <- matrix(c(2,1.5,1.8,1.5,3,2.2,1.8,2.2,3.5),ncol=3) shape1 <- c(1,2) shape2 <- c(1,2,1.5) dens1 <- dmesn(x=c(1,1), scale=sigma1, shape=shape1, extended=2) dens2 <- dmesn(x=c(1,1), scale=sigma1) dens3 <- dmesn(x=c(1,1,1), scale=sigma2, shape=shape2, extended=2) dens4 <- dmesn(x=c(1,1,1), scale=sigma2) prob1 <- pmesn(x=c(1,1), scale=sigma1, shape=shape1, extended=2) prob2 <- pmesn(x=c(1,1), scale=sigma1) prob3 <- pmesn(x=c(1,1,1), scale=sigma2, shape=shape2, extended=2) prob4 <- pmesn(x=c(1,1,1), scale=sigma2)
Density function, distribution function for the bivariate and trivariate extended skew-t (EST) distribution.
dmest(x=c(0,0), location=rep(0, length(x)), scale=diag(length(x)), shape=rep(0,length(x)), extended=0, df=Inf) pmest(x=c(0,0), location=rep(0, length(x)), scale=diag(length(x)), shape=rep(0,length(x)), extended=0, df=Inf)
dmest(x=c(0,0), location=rep(0, length(x)), scale=diag(length(x)), shape=rep(0,length(x)), extended=0, df=Inf) pmest(x=c(0,0), location=rep(0, length(x)), scale=diag(length(x)), shape=rep(0,length(x)), extended=0, df=Inf)
x |
quantile vector of length |
location |
a numeric location vector of length |
scale |
a symmetric positive-definite scale matrix of dimension |
shape |
a numeric skewness vector of length |
extended |
a single value extension parameter. |
df |
a single positive value representing the degree of freedom;
it can be non-integer. Default value is |
density (dmest
), probability (pmest
) from the bivariate or trivariate extended skew-t distribution with given
location
, scale
, shape
, extended
and df
parameters or from the skew-t distribution if extended=0
.
If shape=0
and extended=0
then the t distribution is recovered.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
Azzalini, A. and Capitanio, A. (2003). Distributions generated by perturbation of symmetry with emphasis on a multivariate skew t distribution. J.Roy. Statist. Soc. B 65, 367–389.
Azzalini, A. with the collaboration of Capitanio, A. (2014). The Skew-Normal and Related Families. Cambridge University Press, IMS Monograph series.
sigma1 <- matrix(c(2,1.5,1.5,3),ncol=2) sigma2 <- matrix(c(2,1.5,1.8,1.5,3,2.2,1.8,2.2,3.5),ncol=3) shape1 <- c(1,2) shape2 <- c(1,2,1.5) dens1 <- dmest(x=c(1,1), scale=sigma1, shape=shape1, extended=2, df=1) dens2 <- dmest(x=c(1,1), scale=sigma1, df=1) dens3 <- dmest(x=c(1,1,1), scale=sigma2, shape=shape2, extended=2, df=1) dens4 <- dmest(x=c(1,1,1), scale=sigma2, df=1) prob1 <- pmest(x=c(1,1), scale=sigma1, shape=shape1, extended=2, df=1) prob2 <- pmest(x=c(1,1), scale=sigma1, df=1) prob3 <- pmest(x=c(1,1,1), scale=sigma2, shape=shape2, extended=2, df=1) prob4 <- pmest(x=c(1,1,1), scale=sigma2, df=1)
sigma1 <- matrix(c(2,1.5,1.5,3),ncol=2) sigma2 <- matrix(c(2,1.5,1.8,1.5,3,2.2,1.8,2.2,3.5),ncol=3) shape1 <- c(1,2) shape2 <- c(1,2,1.5) dens1 <- dmest(x=c(1,1), scale=sigma1, shape=shape1, extended=2, df=1) dens2 <- dmest(x=c(1,1), scale=sigma1, df=1) dens3 <- dmest(x=c(1,1,1), scale=sigma2, shape=shape2, extended=2, df=1) dens4 <- dmest(x=c(1,1,1), scale=sigma2, df=1) prob1 <- pmest(x=c(1,1), scale=sigma1, shape=shape1, extended=2, df=1) prob2 <- pmest(x=c(1,1), scale=sigma1, df=1) prob3 <- pmest(x=c(1,1,1), scale=sigma2, shape=shape2, extended=2, df=1) prob4 <- pmest(x=c(1,1,1), scale=sigma2, df=1)
Level sets of the bivariate normal, student-t and skew-normal distributions probability densities for a given probability.
ellipse(center=c(0,0), alpha=c(0,0), sigma=diag(2), df=1, prob=0.01, npoints=250, pos=FALSE)
ellipse(center=c(0,0), alpha=c(0,0), sigma=diag(2), df=1, prob=0.01, npoints=250, pos=FALSE)
center |
A vector of length 2 corresponding to the location of the distribution. |
alpha |
A vector of length 2 corresponding to the skewness of the skew-normal distribution. |
sigma |
A 2 by 2 variance-covariance matrix. |
df |
An integer corresponding to the degree of freedom of the student-t distribution. |
prob |
The probability level. See |
npoints |
The maximum number of points at which it is evaluated. |
pos |
If |
The Level sets are defined as
where is the largest constant such that
.
Here we consider
to be the bivariate normal, student-t or skew-normal density.
Returns a bivariate vector of rows if
pos=FALSE
, and half otherwise.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
library(mvtnorm) # Data simulation (Bivariate-t on positive quadrant) rho <- 0.5 sigma <- matrix(c(1,rho,rho,1), ncol=2) df <- 2 set.seed(101) n <- 1500 data <- rmvt(5*n, sigma=sigma, df=df) data <- data[data[,1]>0 & data[,2]>0, ] data <- data[1:n, ] P <- c(1/750, 1/1500, 1/3000) ell1 <- ellipse(prob=1-P[1], sigma=sigma, df=df, pos=TRUE) ell2 <- ellipse(prob=1-P[2], sigma=sigma, df=df, pos=TRUE) ell3 <- ellipse(prob=1-P[3], sigma=sigma, df=df, pos=TRUE) plot(data, xlim=c(0,max(data[,1],ell1[,1],ell2[,1],ell3[,1])), ylim=c(0,max(data[,2],ell1[,2],ell2[,2],ell3[,2])), pch=19) points(ell1, type="l", lwd=2, lty=1) points(ell2, type="l", lwd=2, lty=1) points(ell3, type="l", lwd=2, lty=1)
library(mvtnorm) # Data simulation (Bivariate-t on positive quadrant) rho <- 0.5 sigma <- matrix(c(1,rho,rho,1), ncol=2) df <- 2 set.seed(101) n <- 1500 data <- rmvt(5*n, sigma=sigma, df=df) data <- data[data[,1]>0 & data[,2]>0, ] data <- data[1:n, ] P <- c(1/750, 1/1500, 1/3000) ell1 <- ellipse(prob=1-P[1], sigma=sigma, df=df, pos=TRUE) ell2 <- ellipse(prob=1-P[2], sigma=sigma, df=df, pos=TRUE) ell3 <- ellipse(prob=1-P[3], sigma=sigma, df=df, pos=TRUE) plot(data, xlim=c(0,max(data[,1],ell1[,1],ell2[,1],ell3[,1])), ylim=c(0,max(data[,2],ell1[,2],ell2[,2],ell3[,2])), pch=19) points(ell1, type="l", lwd=2, lty=1) points(ell2, type="l", lwd=2, lty=1) points(ell3, type="l", lwd=2, lty=1)
Computes the extreme-quantiles of a univariate random variable corresponding to some exceedance probabilities.
ExtQ(P=NULL, method="Frequentist", pU=NULL, cov=NULL, param=NULL, param_post=NULL)
ExtQ(P=NULL, method="Frequentist", pU=NULL, cov=NULL, param=NULL, param_post=NULL)
P |
A vector with values in |
method |
A character string indicating the estimation method. Takes value |
pU |
A value in |
cov |
A |
param |
A |
param_post |
A |
The first column of cov
is a vector of 1s corresponding to the intercept.
When pU
is NULL
(default), then it is assumed that a block maxima approach was taken and quantiles are computed using the qGEV
function. When pU
is provided, the it is assumed that a threshold exceedances approach is taken and the quantiles are computed as
When method=="frequentist"
, the function returns a vector of length length(P)
if ncol(cov)=1
(constant mean) or a (length(P) x nrow(cov))
matrix if ncol(cov)>1
.
When method=="bayesian"
, the function returs a (length(param_post) x length(P))
matrix if ncol(cov)=1
or a list of ncol(cov)
elements each taking a (length(param_post) x length(P))
matrix if ncol(cov)>1
.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com
Beranger, B., Padoan, S. A. and Sisson, S. A. (2021). Estimation and uncertainty quantification for extreme quantile regions. Extremes, 24, 349-375.
################################################## ### Example - Pollution levels in Milan, Italy ### ################################################## ## Not run: data(MilanPollution) # Frequentist estimation fit <- fGEV(Milan.winter$PM10) fit$est q1 <- ExtQ(P=1/c(600,1200,2400), method="Frequentist", param=fit$est) q1 # Bayesian estimation with high threshold cov <- cbind(rep(1,nrow(Milan.winter)), Milan.winter$MaxTemp, Milan.winter$MaxTemp^2) u <- quantile(Milan.winter$PM10, prob=0.9, type=3, na.rm=TRUE) fit2 <- fGEV(data=Milan.winter$PM10, par.start=c(50,0,0,20,1), method="Bayesian", u=u, cov=cov, sig0=0.1, nsim=5e+4) r <- range(Milan.winter$MaxTemp, na.rm=TRUE) t <- seq(from=r[1], to=r[2], length=50) pU <- mean(Milan.winter$PM10>u, na.rm=TRUE) q2 <- ExtQ(P=1/c(600,1200,2400), method="Bayesian", pU=pU, cov=cbind(rep(1,50), t, t^2), param_post=fit2$param_post[-c(1:3e+4),]) R <- c(min(unlist(q2)), 800) qseq <- seq(from=R[1],to=R[2], length=512) Xl <- "Max Temperature" Yl <- expression(PM[10]) for(i in 1:length(q2)){ K_q2 <- apply(q2[[i]],2, function(x) density(x, from=R[1], to=R[2])$y) D <- cbind(expand.grid(t, qseq), as.vector(t(K_q2)) ) colnames(D) <- c("x","y","z") fields::image.plot(x=t, y=qseq, z=matrix(D$z, 50, 512), xlim=r, ylim=R, xlab=Xl, ylab=Yl) } ## End(Not run) ########################################################## ### Example - Simulated data from Frechet distirbution ### ########################################################## if(interactive()){ set.seed(999) data <- extraDistr::rfrechet(n=1500, mu=3, sigma=1, lambda=1/3) u <- quantile(data, probs=0.9, type=3) fit3 <- fGEV(data=data, par.start=c(1,2,1), method="Bayesian", u=u, sig0=1, nsim=5e+4) pU <- mean(data>u) P <- 1/c(750,1500,3000) q3 <- ExtQ(P=P, method="Bayesian", pU=pU, param_post=fit3$param_post[-c(1:3e+4),]) ### Illustration # Tail index estimation ti_true <- 3 ti_ps <- fit3$param_post[-c(1:3e+4),3] K_ti <- density(ti_ps) # KDE of the tail index H_ti <- hist(ti_ps, prob=TRUE, col="lightgrey", ylim=range(K_ti$y), main="", xlab="Tail Index", cex.lab=1.8, cex.axis=1.8, lwd=2) ti_ic <- quantile(ti_ps, probs=c(0.025, 0.975)) points(x=ti_ic, y=c(0,0), pch=4, lwd=4) lines(K_ti, lwd = 2, col = "dimgrey") abline(v=ti_true, lwd=2) abline(v=mean(ti_ps), lwd=2, lty=2) # Quantile estimation q3_true <- extraDistr::qfrechet(p=P, mu=3, sigma=1, lambda=1/3, lower.tail=FALSE) ci <- apply(log(q3), 2, function(x) quantile(x, probs=c(0.025, 0.975))) K_q3 <- apply(log(q3), 2, density) R <- range(log(c(q3_true, q3, data))) Xlim <- c(log(quantile(data, 0.95)), R[2]) Ylim <- c(0, max(K_q3[[1]]$y, K_q3[[2]]$y, K_q3[[3]]$y)) plot(0, main="", xlim=Xlim, ylim=Ylim, xlab=expression(log(x)), ylab="Density", cex.lab=1.8, cex.axis=1.8, lwd=2) cval <- c(211, 169, 105) for(j in 1:length(P)){ col <- rgb(cval[j], cval[j], cval[j], 0.8*255, maxColorValue=255) col2 <- rgb(cval[j], cval[j], cval[j], 255, maxColorValue=255) polygon(K_q3[[j]], col=col, border=col2, lwd=4) } points(log(data), rep(0,n), pch=16) # add posterior means abline(v=apply(log(q3),2,mean), lwd=2, col=2:4) # add credible intervals abline(v=ci[1,], lwd=2, lty=3, col=2:4) abline(v=ci[2,], lwd=2, lty=3, col=2:4) }
################################################## ### Example - Pollution levels in Milan, Italy ### ################################################## ## Not run: data(MilanPollution) # Frequentist estimation fit <- fGEV(Milan.winter$PM10) fit$est q1 <- ExtQ(P=1/c(600,1200,2400), method="Frequentist", param=fit$est) q1 # Bayesian estimation with high threshold cov <- cbind(rep(1,nrow(Milan.winter)), Milan.winter$MaxTemp, Milan.winter$MaxTemp^2) u <- quantile(Milan.winter$PM10, prob=0.9, type=3, na.rm=TRUE) fit2 <- fGEV(data=Milan.winter$PM10, par.start=c(50,0,0,20,1), method="Bayesian", u=u, cov=cov, sig0=0.1, nsim=5e+4) r <- range(Milan.winter$MaxTemp, na.rm=TRUE) t <- seq(from=r[1], to=r[2], length=50) pU <- mean(Milan.winter$PM10>u, na.rm=TRUE) q2 <- ExtQ(P=1/c(600,1200,2400), method="Bayesian", pU=pU, cov=cbind(rep(1,50), t, t^2), param_post=fit2$param_post[-c(1:3e+4),]) R <- c(min(unlist(q2)), 800) qseq <- seq(from=R[1],to=R[2], length=512) Xl <- "Max Temperature" Yl <- expression(PM[10]) for(i in 1:length(q2)){ K_q2 <- apply(q2[[i]],2, function(x) density(x, from=R[1], to=R[2])$y) D <- cbind(expand.grid(t, qseq), as.vector(t(K_q2)) ) colnames(D) <- c("x","y","z") fields::image.plot(x=t, y=qseq, z=matrix(D$z, 50, 512), xlim=r, ylim=R, xlab=Xl, ylab=Yl) } ## End(Not run) ########################################################## ### Example - Simulated data from Frechet distirbution ### ########################################################## if(interactive()){ set.seed(999) data <- extraDistr::rfrechet(n=1500, mu=3, sigma=1, lambda=1/3) u <- quantile(data, probs=0.9, type=3) fit3 <- fGEV(data=data, par.start=c(1,2,1), method="Bayesian", u=u, sig0=1, nsim=5e+4) pU <- mean(data>u) P <- 1/c(750,1500,3000) q3 <- ExtQ(P=P, method="Bayesian", pU=pU, param_post=fit3$param_post[-c(1:3e+4),]) ### Illustration # Tail index estimation ti_true <- 3 ti_ps <- fit3$param_post[-c(1:3e+4),3] K_ti <- density(ti_ps) # KDE of the tail index H_ti <- hist(ti_ps, prob=TRUE, col="lightgrey", ylim=range(K_ti$y), main="", xlab="Tail Index", cex.lab=1.8, cex.axis=1.8, lwd=2) ti_ic <- quantile(ti_ps, probs=c(0.025, 0.975)) points(x=ti_ic, y=c(0,0), pch=4, lwd=4) lines(K_ti, lwd = 2, col = "dimgrey") abline(v=ti_true, lwd=2) abline(v=mean(ti_ps), lwd=2, lty=2) # Quantile estimation q3_true <- extraDistr::qfrechet(p=P, mu=3, sigma=1, lambda=1/3, lower.tail=FALSE) ci <- apply(log(q3), 2, function(x) quantile(x, probs=c(0.025, 0.975))) K_q3 <- apply(log(q3), 2, density) R <- range(log(c(q3_true, q3, data))) Xlim <- c(log(quantile(data, 0.95)), R[2]) Ylim <- c(0, max(K_q3[[1]]$y, K_q3[[2]]$y, K_q3[[3]]$y)) plot(0, main="", xlim=Xlim, ylim=Ylim, xlab=expression(log(x)), ylab="Density", cex.lab=1.8, cex.axis=1.8, lwd=2) cval <- c(211, 169, 105) for(j in 1:length(P)){ col <- rgb(cval[j], cval[j], cval[j], 0.8*255, maxColorValue=255) col2 <- rgb(cval[j], cval[j], cval[j], 255, maxColorValue=255) polygon(K_q3[[j]], col=col, border=col2, lwd=4) } points(log(data), rep(0,n), pch=16) # add posterior means abline(v=apply(log(q3),2,mean), lwd=2, col=2:4) # add credible intervals abline(v=ci[1,], lwd=2, lty=3, col=2:4) abline(v=ci[2,], lwd=2, lty=3, col=2:4) }
This function estimates the parameters of extremal dependence models.
fExtDep(method="PPP", data, model, par.start = NULL, c = 0, optim.method = "BFGS", trace = 0, sig = 3, Nsim, Nbin = 0, Hpar, MCpar, seed = NULL)
fExtDep(method="PPP", data, model, par.start = NULL, c = 0, optim.method = "BFGS", trace = 0, sig = 3, Nsim, Nbin = 0, Hpar, MCpar, seed = NULL)
method |
A character string indicating the estimation method inlcuding |
data |
A matrix containing the data. |
model |
A character string with the name of the model. When |
par.start |
A vector representing the initial parameters values for the optimization algorithm. |
c |
A real value in |
optim.method |
A character string indicating the optimization algorithm. Required when |
trace |
A non-negative integer, tracing the progress of the optimization. Required when |
sig |
An integer indicating the number of significant digits when reporting outputs. |
Nsim |
An integer indicating the number of MCMC simulations. Required when |
Nbin |
An integer indicating the length of the burn-in period. Required when |
Hpar |
A list of hyper-parameters. See 'details'. Required when |
MCpar |
A positive real representing the variance of the proposal distirbution. See 'details'. Required when |
seed |
An integer indicating the seed to be set for reproducibility, via the routine |
When method="PPP"
the approximate likelihood is used to estimate the model parameters. It relies on the dExtDep
function with argument method="Parametric"
and angular=TRUE
.
When method="BayesianPPP"
a Bayesian estimation procedure of the spatral measure is considered, following Sabourin et al. (2013) and Sabourin & Naveau (2014). The argument Hpar
is required to specify the hyper-parameters of the prior distributions, taking the following into consideration:
For the Pairwise Beta model, the parameters components are independent, log-normal.
The vector of parameters is of size choose(dim,2)+1
with positive components. The first elements are the
pairiwse dependence parameters b
and the last one is the global dependence parameter alpha
.
The list of hyper-parameters should be of the form
mean.alpha=, mean.beta=, sd.alpha=, sd.beta=
;
For the Husler-Reiss model, the parameters are independent, log-normally distributed.
The elements correspond to the lambda
parameter. The list of hyper-parameters should be of the form mean.lambda=, sd.lambda=
;
For the Dirichlet model, the parameters are independent, log-normally distributed.
The elements correspond to the alpha
parameter. The list of hyper-parameters should be of the form mean.alpha=, sd.alpha=
;
For the Extremal-t model, the parameters are independent, logit-squared for rho
and log-normal for mu
. The first elements correspond to the correlation parameters rho
and the last parameter is the global dependence parameter mu
. The list of hyper-parameters should be of the form mean.rho=, mean.mu=, sd.rho=, sd.mu=
;
For the Extremal skewt-t model, the parameters are independent, logit-squared for rho
, normal for alpha
and log-normal for mu
. The first elements correspond to the correlation parameters rho
, then the skewness parameters alpha
and the last parameter is the global dependence parameter mu
. The list of hyper-parameters should be of the form mean.rho=, mean.alpha=, mean.mu=, sd.rho=, sd.alpha=, sd.mu=
;
For the Asymmetric Logistic model, the parameters' components are independent, log-normal for alpha
and logit for beta
. The list of hyper-parameters should be of the form mean.alpha=, mean.beta=, sd.alpha=, sd.beta=
.
The proposal distribution for each (transformed) parameter is a normal distribution centred on the (transformed) current parameter value, with variance MCpar
.
When method="Composite"
, the pairwise composite likelihood is applied, based on the dExtDep
function with argument method="Parametric"
and angular=FALSE
.
When method == "PPP"
or "Composite"
, a list is returned including
The estimated parameters.
The maximised log-likelihood.
The standard errors.
The Takeuchi Information Criterion.
When method == "BayesianPPP"
, a list is returned including
A matrix, where
is the dimension of the parameter space
A vector of size containing the log-likelihoods evaluadted at each parameter
of the posterior sample.
A vector of size containing the logarithm of the prior densities evaluated
at each parameter of the posterior sample.
The specifics of the algorithm.
The time elapsed, as given by proc.time
between the start and end of the run.
The same as the passed argument.
Idem.
The total number of accepted proposals.
The number of accepted proposals after the burn-in period.
The estimated posterior parameters mean.
The empirical posterior sample standard deviation.
The Bayesian Information Criteria.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
Beranger, B. and Padoan, S. A. (2015). Extreme dependence models, chapater of the book Extreme Value Modeling and Risk Analysis: Methods and Applications, Chapman Hall/CRC.
Sabourin, A., Naveau, P. and Fougeres, A-L (2013) Bayesian model averaging for multivariate extremes Extremes, 16, 325-350.
Sabourin, A. and Naveau, P. (2014) Bayesian Dirichlet mixture model for multivariate extremes: A re-parametrization Computational Statistics & Data Analysis, 71, 542-567.
dExtDep
, pExtDep
, rExtDep
, fExtDep.np
# Example using the Poisson Point Proce Process appraoch data(pollution) f.hr <- fExtDep(method="PPP", data=PNS, model="HR", par.start = rep(0.5, 3), trace=2) # Example using the pairwise composite (full) likelihood set.seed(1) data <- rExtDep(n=300, model="ET", par=c(0.6,3)) f.et <- fExtDep(method="Composite", data=data, model="ET", par.start = c(0.5, 1), trace=2)
# Example using the Poisson Point Proce Process appraoch data(pollution) f.hr <- fExtDep(method="PPP", data=PNS, model="HR", par.start = rep(0.5, 3), trace=2) # Example using the pairwise composite (full) likelihood set.seed(1) data <- rExtDep(n=300, model="ET", par=c(0.6,3)) f.et <- fExtDep(method="Composite", data=data, model="ET", par.start = c(0.5, 1), trace=2)
This function estimates the bivariate extremal dependence structure using a non-parametric approach based on Bernstein Polynomials.
fExtDep.np(method, data, cov1=NULL, cov2=NULL, u, mar.fit=TRUE, mar.prelim=TRUE, par10, par20, sig10, sig20, param0=NULL, k0=NULL, pm0=NULL, prior.k="nbinom", prior.pm="unif", nk=70, lik=TRUE, hyperparam = list(mu.nbinom=3.2, var.nbinom=4.48), nsim, warn=FALSE, type="rawdata")
fExtDep.np(method, data, cov1=NULL, cov2=NULL, u, mar.fit=TRUE, mar.prelim=TRUE, par10, par20, sig10, sig20, param0=NULL, k0=NULL, pm0=NULL, prior.k="nbinom", prior.pm="unif", nk=70, lik=TRUE, hyperparam = list(mu.nbinom=3.2, var.nbinom=4.48), nsim, warn=FALSE, type="rawdata")
method |
A character string indicating the estimation method inlcuding |
data |
A matrix containing the data. |
cov1 , cov2
|
A covariate vector/matrix for linear model on the location parameter of the marginal distributions. |
u |
When |
mar.fit |
A logical value indicated whether the marginal distributions should be fitted. When |
rawdata |
A character string specifying if the data is |
mar.prelim |
A logical value indicated whether a preliminary fit of marginal distributions should be done prior to estimating the margins and dependence. Required when |
par10 , par20
|
Vectors of starting values for the marginal parameter estimation. Required when |
sig10 , sig20
|
Positive reals representing the initial value for the scaling parameter of the multivariate normal proposal distribution for both margins. Required when |
param0 |
A vector of initial value for the Bernstein polynomial coefficients. It should be a list with elements |
k0 |
An integer indicating the initial value of the polynomial order. Required when |
pm0 |
A list of initial values for the probability masses at the boundaries of the simplex. It should be a list with two elements |
prior.k |
A character string indicating the prior distribution on the polynomial order. By default |
prior.pm |
A character string indicating the prior on the probability masses at the endpoints of the simplex. By default |
nk |
An integer indicating the maximum polynomial order. Required when |
lik |
A logical value; if |
hyperparam |
A list of the hyper-parameters depending on the choice of |
nsim |
An integer indicating the number of iterations in the Metropolis-Hastings algorithm. Required when |
warn |
A logical value. If |
type |
A character string indicating whther the data are |
When method="Bayesian"
, the vector of hyper-parameters is provided in the argument hyperparam
. It should include:
prior.pm="unif"
requires hyperparam$a.unif
and hyperparam$b.unif
.
prior.pm="beta"
requires hyperparam$a.beta
and hyperparam$b.beta
.
prior.k="pois"
requires hyperparam$mu.pois
.
prior.k="nbinom"
requires hyperparam$mu.nbinom
and hyperparam$var.nbinom
or hyperparam$pnb
and hyperparam$rnb
. The relationship is pnb = mu.nbinom/var.nbinom
and rnb = mu.nbinom^2 / (var.nbinom-mu.nbinom)
.
When u
is specified Algorithm 1 of Beranger et al. (2021) is applied whereas when it is not specified Algorithm 3.5 of Marcon et al. (2016) is considered.
When method="Frequentist"
, if type="rawdata"
then pseudo-polar coordinates are extracted and only observations with a radial component above some high threshold (the quantile equivalent of u
for the raw data) are retained. The inferential approach proposed in Marcon et al. (2017) based on the approximate likelihood is applied.
When method="Empirical"
, the empirical estimation procedure presented in Einmahl et al. (2013) is applied.
Outputs take the form of list including:
The argument.
whether it is "maxima"
or "rawdata"
(in the broader sense that a threshold exceedance model was taken).
If method="Bayesian"
the list also includes:
The argument.
The posterior sample of probability masses.
The posterior sample for the coeficients of the Bernstein polynomial.
The posterior sample for the Bernstein polynoial order.
A binary vector indicating if the proposal was accepted.
A vector containing the acceptance probabilities for the dependence parameters at each iteration.
A list containing hyperparam
, prior.pm
and prior.k
.
The argument.
The argument.
In addition if the marginal parameters are estimated (mar.fit=TRUE
):
The arguments.
Binary vectors indicating if the marginal proposals were accepted.
Binary vectors indicating if the marginal proposals were rejected straight away as not respecting existence conditions (proposal is multivariate normal).
Vectors containing the acceptance probabilities for the marginal parameters at each iteration.
Vectors containing the values of the scaling parameter in the marginal proposal distributions.
Finally, if the argument u
is provided, the list also contains:
A bivariate vector indicating the threshold level for both margins.
The empirical estimate of the probability of being greater than the threshold.
When method="Frequentist"
, the list includes:
When method="Empirical"
, the list includes:
An estimate of the angular density.
An estimate of the angular measure.
The estimates of the probability mass at 0 and 1.
An estimate of the PIckands dependence function.
A sequence of value on the bivariate unit simplex.
A real in indicating the quantile associated with the threshold
u
. Takes value NULL
if type="maxima"
.
The data on the unit Frechet scale (empirical transformation) if type="rawdata"
and mar.fit=TRUE
. Data on the original scale otherwise.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
Beranger, B., Padoan, S. A. and Sisson, S. A. (2021). Estimation and uncertainty quantification for extreme quantile regions. Extremes, 24, 349-375.
Einmahl, J. H. J., de Haan, L. and Krajina, A. (2013). Estimating extreme bivariate quantile regions. Extremes, 16, 121-145.
Marcon, G., Padoan, S. A. and Antoniano-Villalobos, I. (2016). Bayesian inference for the extremal dependence. Electronic Journal of Statistics, 10, 3310-3337.
Marcon, G., Padoan, S.A., Naveau, P., Muliere, P. and Segers, J. (2017) Multivariate Nonparametric Estimation of the Pickands Dependence Function using Bernstein Polynomials. Journal of Statistical Planning and Inference, 183, 1-17.
dExtDep
, pExtDep
, rExtDep
, fExtDep
# Example Bayesian estimation, # Threshold exceedances approach, threshold set by default # Joint estimation margins + dependence # Default uniform prior on pm # Default negative binomial prior on polynomial order # Quadratic relationship between location and max temperature ## Not run: data(MilanPollution) data <- Milan.winter[,c("NO2", "SO2", "MaxTemp")] data <- data[complete.cases(data),] covar <- cbind(rep(1,nrow(data)), data[,3], data[,3]^2) hyperparam <- list(mu.binom=6, var.binom=8, a.unif=0, b.unif=0.2) pollut <- fExtDep.np(method="Bayesian", data = data[,-3], u=TRUE, cov1 = covar, cov2 = covar, mar.prelim=FALSE, par10 = c(100,0,0,35,1), par20 = c(20,0,0,20,1), sig10 = 0.1, sig20 = 0.1, k0 = 5, hyperparam = hyperparam, nsim = 5e+4) # Warning: This is slow! ## End(Not run) # Example Frequentist estimation # Data are maxima data(WindSpeedGust) years <- format(ParcayMeslay$time, format="%Y") attach(ParcayMeslay[which(years %in% c(2004:2013)),]) WS_th <- quantile(WS,.9) DP_th <- quantile(DP,.9) pars.WS <- evd::fpot(WS, WS_th, model="pp")$estimate pars.DP <- evd::fpot(DP, DP_th, model="pp")$estimate data_uf <- trans2UFrechet(cbind(WS,DP), type="Empirical") rdata <- rowSums(data_uf) r0 <- quantile(rdata, probs=.90) extdata <- data_uf[rdata>=r0,] SP_mle <- fExtDep.np(method="Frequentist", data=extdata, k0=10, type="maxima")
# Example Bayesian estimation, # Threshold exceedances approach, threshold set by default # Joint estimation margins + dependence # Default uniform prior on pm # Default negative binomial prior on polynomial order # Quadratic relationship between location and max temperature ## Not run: data(MilanPollution) data <- Milan.winter[,c("NO2", "SO2", "MaxTemp")] data <- data[complete.cases(data),] covar <- cbind(rep(1,nrow(data)), data[,3], data[,3]^2) hyperparam <- list(mu.binom=6, var.binom=8, a.unif=0, b.unif=0.2) pollut <- fExtDep.np(method="Bayesian", data = data[,-3], u=TRUE, cov1 = covar, cov2 = covar, mar.prelim=FALSE, par10 = c(100,0,0,35,1), par20 = c(20,0,0,20,1), sig10 = 0.1, sig20 = 0.1, k0 = 5, hyperparam = hyperparam, nsim = 5e+4) # Warning: This is slow! ## End(Not run) # Example Frequentist estimation # Data are maxima data(WindSpeedGust) years <- format(ParcayMeslay$time, format="%Y") attach(ParcayMeslay[which(years %in% c(2004:2013)),]) WS_th <- quantile(WS,.9) DP_th <- quantile(DP,.9) pars.WS <- evd::fpot(WS, WS_th, model="pp")$estimate pars.DP <- evd::fpot(DP, DP_th, model="pp")$estimate data_uf <- trans2UFrechet(cbind(WS,DP), type="Empirical") rdata <- rowSums(data_uf) r0 <- quantile(rdata, probs=.90) extdata <- data_uf[rdata>=r0,] SP_mle <- fExtDep.np(method="Frequentist", data=extdata, k0=10, type="maxima")
This function uses the Stephenson-Tawn likelihood to estimate parameters of max-stable models.
fExtDepSpat(model, z, sites, hit, jw, thresh, DoF, range, smooth, alpha, par0, acov1, acov2, parallel, ncores, args1, args2, seed=123, method = "BFGS", sandwich=TRUE, control = list(trace=1, maxit=50, REPORT=1, reltol=0.0001))
fExtDepSpat(model, z, sites, hit, jw, thresh, DoF, range, smooth, alpha, par0, acov1, acov2, parallel, ncores, args1, args2, seed=123, method = "BFGS", sandwich=TRUE, control = list(trace=1, maxit=50, REPORT=1, reltol=0.0001))
model |
A character string indicating the max-stable model, currently extremal-t ( |
z |
A |
sites |
A |
hit |
A |
jw |
An integer between |
thresh |
A positive real indicating the threshold value for pairwise distances. See |
DoF |
A positive real indicating a fixed value of the degree of freedom of the extremal-t and extremal skew-t models. |
range |
A positive real indicating a fixed value of the range parameter for the power exponential correlation function (only correlation function currently available). |
smooth |
A positive real in |
alpha |
A vector of length |
par0 |
A vector of initial value of the parameter vector, in order the degree of freedom |
acov1 , acov2
|
Vectors of length |
parallel |
A logical value; if |
ncores |
An integer indicating the number of cores considered in the parallel socket cluster of type |
args1 , args2
|
Lists specifying details about the Monte Carlo simulation schereme to compute multivariate CDFs. See |
seed |
An integer for reproduciblity in the CDF computations. |
method |
A character string indicating the optimisation method to be used. See |
sandwich |
A logical value; if |
control |
A list of control parameter for the optimisation. See |
This routine follows the methodology developped by Beranger et al. (2021). It uses on the Stephenson-Tawn which relies on the knowledge of time occurrences of each block maxima. Rather than considering all partitions of the set , the likelihood is computed using the observed partition. Let
denote the observed partition, then the Stephenson-Tawn likelihood is given by
where represents the partial derivative(s) of
with respect to
.
When jw=d
the full Stephenson-Tawn likelihood is considered whereas for values lower than a composite likelihood approach is taken.
The argument thresh
is required when the composite likelihood is used. A tuple of size jw
, is assigned a weight of one if the maximum pairwise distance between corresponding locations is less that thresh
and a weight of zero otherwise.
Arguments args1
and args2
relate to specifications of the Monte Carlo simulation scheme to compute multivariate CDF evaluations. These should take the form of lists including the minimum and maximum number of simulations used (Nmin
and Nmax
), the absolute error (eps
) and whether the error should be controlled on the log-scale (logeps
).
A list comprising of the vector of estimated parameters (est
), the composite likelihood order (jw
), the maximised log-likelihood value (LL
). In addition, if sandwich=TRUE
the the standard errors from the sandwich information matrix are reported via stderr.sand
as well as the TIC for model selection (TIC
). Finally, if the composite likelihood is considered, a matrix with all tuples considered with a weight of 1 are reported in cmat
.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
Beranger, B., Stephenson, A. G. and Sisson, S.A. (2021) High-dimensional inference using the extremal skew-t process Extremes, 24, 653-685.
set.seed(14342) # Simulation of 20 locations Ns <- 20 sites <- matrix(runif(Ns*2)*10-5,nrow=Ns,ncol=2) for(i in 1:2) sites[,i] <- sites[,i] - mean(sites[,i]) # Simulation of 50 replicates from the Extremal-t model Ny <- 50 z <- rExtDepSpat(Ny, sites, model="ET", cov.mod="powexp", DoF=1, range=3, nugget=0, smooth=1.5, control=list(method="exact")) # Fit the extremal-t using the full Stephenson-Tawn likelihood args1 <- list(Nmax=50L, Nmin=5L, eps=0.001, logeps=FALSE) args2 <- list(Nmax=500L, Nmin=50L, eps=0.001, logeps=TRUE) ## Not run: fit1 <- fExtDepSpat(model="ET", z=z$vals, sites=sites, hit=z$hits, par0=c(3,1,1), parallel=TRUE, ncores=6, args1=args1, args2=args2, control = list(trace=0)) fit1$est ## End(Not run)
set.seed(14342) # Simulation of 20 locations Ns <- 20 sites <- matrix(runif(Ns*2)*10-5,nrow=Ns,ncol=2) for(i in 1:2) sites[,i] <- sites[,i] - mean(sites[,i]) # Simulation of 50 replicates from the Extremal-t model Ny <- 50 z <- rExtDepSpat(Ny, sites, model="ET", cov.mod="powexp", DoF=1, range=3, nugget=0, smooth=1.5, control=list(method="exact")) # Fit the extremal-t using the full Stephenson-Tawn likelihood args1 <- list(Nmax=50L, Nmin=5L, eps=0.001, logeps=FALSE) args2 <- list(Nmax=500L, Nmin=50L, eps=0.001, logeps=TRUE) ## Not run: fit1 <- fExtDepSpat(model="ET", z=z$vals, sites=sites, hit=z$hits, par0=c(3,1,1), parallel=TRUE, ncores=6, args1=args1, args2=args2, control = list(trace=0)) fit1$est ## End(Not run)
Maximum-likelihood and Metropolis-Hastings algorithm for the estimation of the generalized extreme value distribution.
fGEV(data, par.start, method="Frequentist", u, cov, optim.method="BFGS", optim.trace=0, sig0, nsim)
fGEV(data, par.start, method="Frequentist", u, cov, optim.method="BFGS", optim.trace=0, sig0, nsim)
data |
A vector representing the data, which may contain missing values. |
par.start |
A vector of length |
method |
A character string indicating whether the estimation is done following a |
u |
A real indicating a high threshold. If supplied a threshld exceedance approach is taken and computations use the censored likelihood. If missing, a block maxima approach is taken and the regular GEV likelihood is used. |
cov |
A matrix of covariates to define a linear model for the location parameter. |
optim.method |
The optimization method to be used. Required when |
optim.trace |
A non-negative interger tracing the progress of the optimization. Required when |
sig0 |
Positive reals representing the initial value for the scaling parameter of the multivariate normal proposal distribution for both margins. Required when |
nsim |
An integer indicating the number of iterations in the Metropolis-Hastings algorithm. Required when |
When cov
is a vector of ones then the location parameter is constant. On the contrary, when
cov
is provided, it represents the design matrix for the linear model on (the number of columns in the matrix indicates the number of linear predictors).
When
u=NULL
or missing, the likelihood function is given by
where represents the GEV pdf, whereas when a threshold value is set the likelihood is given by
where is the GEV cdf and
is the empirical estimate of the probability of being greater than the threshold
u
.
Note that the case is not yet considered when
u
is considered.
The choice method="Bayesian"
applies a random walk Metropolis-Hastings algorithm as described in Section 3.1 and Step 1 and 2 of Algorithm 1 from Beranger et al. (2021). The algorithm may restart for several reasons including if the proposed value of the parameters changes too much from the current value (see Garthwaite et al. (2016) for more details.)
The choice method="Frequentist"
uses the optim
function to find the maximum likelihood estimator.
When method="Frequentist"
the routine returns a list including the parameter estimates (est
) and associated variance-covariance matrix (varcov
) and standard errors (stderr
).
When method="Bayesian"
the routine returns a list including
the parameter posterior sample;
a binary vector indicating which proposal was accepted;
a binary vector indicating which proposal were rejected straight away given that the proposal is a multivariate normal and there are conditions on the parameter values;
the number of simulations in the algorithm;
the vector of updated scaling parameter in the multivariate normal porposal distribution at each iteration;
the value of the scaling parameter in the multivariate normal porposal distribution when the algorithm needs to restart;
a vector of acceptance probabilities at each iteration.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
Beranger, B., Padoan, S. A. and Sisson, S. A. (2021). Estimation and uncertainty quantification for extreme quantile regions. Extremes, 24, 349-375.
Garthwaite, P. H., Fan, Y. and Sisson S. A. (2016). Adaptive optimal scaling of Metropolis-Hastings algorithms using the Robbins-Monro process. Communications in Statistics - Theory and Methods, 45(17), 5098-5111.
################################################## ### Example - Pollution levels in Milan, Italy ### ################################################## data(MilanPollution) # Frequentist estimation fit <- fGEV(Milan.winter$PM10) fit$est # Bayesian estimation with high threshold cov <- cbind(rep(1,nrow(Milan.winter)), Milan.winter$MaxTemp, Milan.winter$MaxTemp^2) u <- quantile(Milan.winter$PM10, prob=0.9, type=3, na.rm=TRUE) fit2 <- fGEV(data=Milan.winter$PM10, par.start=c(50,0,0,20,1), method="Bayesian", u=u, cov=cov, sig0=0.1, nsim=5e+4)
################################################## ### Example - Pollution levels in Milan, Italy ### ################################################## data(MilanPollution) # Frequentist estimation fit <- fGEV(Milan.winter$PM10) fit$est # Bayesian estimation with high threshold cov <- cbind(rep(1,nrow(Milan.winter)), Milan.winter$MaxTemp, Milan.winter$MaxTemp^2) u <- quantile(Milan.winter$PM10, prob=0.9, type=3, na.rm=TRUE) fit2 <- fGEV(data=Milan.winter$PM10, par.start=c(50,0,0,20,1), method="Bayesian", u=u, cov=cov, sig0=0.1, nsim=5e+4)
The dataset corresponds to the summer maxima taken over the period from August to April inclusive, recorded between 1961 and 2010 at 90 stations on a 0.15 degree grid in a 9 by 10 formation.
The first maximum is taken over the August 1961 to April 1962 period, and the last maximum is taken over the August 2010 to April 2011 period. The object heatdata
contains the core of the data:
A matrix containing the
summer maxima at the
locations.
A matrix containing the sites locations in Latitude-Longitude, recentred (means have been substracted).
A matrix containing the sites locations in Eastings-Northings, recentred (means have been substracted).
A matrix containing integers indicating the “heatwave” number of each of the
summer maxima at all
locations. Locations on the same row with the same integer indicates that they were obtained from the same heatwave. Heatwaves are defined over a three day window.
A matrix containing the sites locations in Latitude-Longitude, on the original scale.
A matrix containing the sites locations in Eastings-Northings, on the original scale.
A matrix containing the
summer maxima at the
locations, on the unit Frechet scale.
Standardisation to unit Frechet is performed as in Beranger et al. (2021) by fitting the GEV distribution marginally using unconstrained location and shape parameters and the shape parameter to be a linear function of eastings and northings in 100 kilometre units. The resulting estimates are given in the objects locgrid
, scalegrid
and shapegrid
, which are matrices.
Details about the study region are given in mellat
and mellon
, vectors of length and
which give the latitude and longitude coordinates of the grid.
Beranger, B., Stephenson, A. G. and Sisson, S.A. (2021) High-dimensional inference using the extremal skew-t process Extremes, 24, 653-685.
image(x=mellon, y=mellat, z=locgrid) points(heatdata$sitesLLO, pch=16)
image(x=mellon, y=mellat, z=locgrid) points(heatdata$sitesLLO, pch=16)
This function computes the extremal coefficient, Pickands dependence function and the coefficients of upper and lower tail dependence for several parametric models and the lower tail dependence function for the bivairate skew-normal distribution.
index.ExtDep(object, model, par, x, u)
index.ExtDep(object, model, par, x, u)
object |
A character string indicating the index of extremal dependence to compute, including the extremal coefficient |
model |
A character string indicating the model/distribution. When |
par |
A vector indicating the parameter values of the corresponding model/distribution. |
x |
A vector on the bivariate or trivariate unit simplex indicating where to evaluate the Pickands dependence function. |
u |
A real in |
The extremal coefficient is defined as
where represents the unit simplex,
is the exponent function and
the distribution function of a multivariate extreme value model. Bivariate and trivariate versions are available.
The Pickands dependence function is defined as for
in the bivariate/trivariate simplex (
).
The coefficient of upper tail dependence is defined as
In the bivariate case, using the inclusion-exclusion principle this reduces to .
For the skew-normal distribution, the lower tail dependence function is defined as in Bortot (2010). This is an approximation where the tail dependence is obtained in the limiting case where u
goes to . The
par
argument should be a vector of length comprising of the correlation parameter, between
and
and two real-valued skewness parameters.
When object="extremal"
, returns a value between and
(
).
When object="pickands"
, returns a value between and
.
When object="upper.tail"
, returns a value between and
.
When object="lower.tail"
, returns a value between and
.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
Bortot, P. (2010) Tail dependence in bivariate skew-normal and skew-t distributions. Unpublished.
############################# ### Extremal skew-t model ### ############################# ### Extremal coefficient index.ExtDep(object="extremal", model="EST", par=c(0.5,1,-2,2)) ### Pickands dependence function w <- seq(0.00001, .99999, length=100) pick <- vector(length=100) for(i in 1:100){ pick[i] <- index.ExtDep(object="pickands", model="EST", par=c(0.5,1,-2,2), x=c(w[i],1-w[i])) } plot(w, pick, type="l", ylim=c(0.5, 1), ylab="A(t)", xlab="t") polygon(c(0, 0.5, 1), c(1, 0.5, 1), lwd=2, border = 'grey') ### Upper tail dependence coefficient index.ExtDep(object="upper.tail", model="EST", par=c(0.5,1,-2,2)) ### Lower tail dependence coefficient index.ExtDep(object="lower.tail", model="EST", par=c(0.5,1,-2,2)) ################################ ### Skew-normal distribution ### ################################ ### Lower tail dependence function index.ExtDep(object="lower.tail", model="SN", par=c(0.5,1,-2), u=0.5)
############################# ### Extremal skew-t model ### ############################# ### Extremal coefficient index.ExtDep(object="extremal", model="EST", par=c(0.5,1,-2,2)) ### Pickands dependence function w <- seq(0.00001, .99999, length=100) pick <- vector(length=100) for(i in 1:100){ pick[i] <- index.ExtDep(object="pickands", model="EST", par=c(0.5,1,-2,2), x=c(w[i],1-w[i])) } plot(w, pick, type="l", ylim=c(0.5, 1), ylab="A(t)", xlab="t") polygon(c(0, 0.5, 1), c(1, 0.5, 1), lwd=2, border = 'grey') ### Upper tail dependence coefficient index.ExtDep(object="upper.tail", model="EST", par=c(0.5,1,-2,2)) ### Lower tail dependence coefficient index.ExtDep(object="lower.tail", model="EST", par=c(0.5,1,-2,2)) ################################ ### Skew-normal distribution ### ################################ ### Lower tail dependence function index.ExtDep(object="lower.tail", model="SN", par=c(0.5,1,-2), u=0.5)
The dataset logReturns
contains 4 columns: date_USD
and USD
give the date of the monthly maxima of the log-return exchange rate GBP/USD and its value while date_JPY
and JPY
give the date of the monthly maxima of the log-return exchange rate GBP/JPY and its value.
A matrix. The first and third columns are objects of type
"character"
while the second and fourth columns are of type "numeric"
.
Computes a non-parametric estimate Pickands dependence function, for multivariate data, based on the madogram estimator.
madogram(w, data, margin = c("emp","est","exp","frechet","gumbel"))
madogram(w, data, margin = c("emp","est","exp","frechet","gumbel"))
w |
|
data |
|
margin |
string, denoting the type marginal distributions ( |
The estimation procedure is based on the madogram as proposed in Marcon et al. (2017). The madogram is defined by
where and
.
Each row of the design matrix w
is a point in the unit
d
-dimensional simplex.
If is a
d
-dimensional max-stable distributed random vector, with exponent measure function and Pickands dependence function
, then
where
.
From this, it follows that
and
An empirical transformation of the marginals is performed when margin="emp"
.
A max-likelihood fitting of the GEV distributions is implemented when margin="est"
.
Otherwise it refers to marginal parametric GEV theorethical distributions (margin="exp", "frechet", "gumbel"
).
A numeric vector of estimates.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com; Giulia Marcon, [email protected]
Marcon, G., Padoan, S.A., Naveau, P., Muliere, P. and Segers, J. (2017) Multivariate Nonparametric Estimation of the Pickands Dependence Function using Bernstein Polynomials. Journal of Statistical Planning and Inference, 183, 1-17.
Naveau, P., Guillou, A., Cooley, D., Diebolt, J. (2009) Modelling pairwise dependence of maxima in space, Biometrika, 96(1), 1-17.
x <- simplex(2) data <- evd::rbvevd(50, dep = 0.4, model = "log", mar1 = c(1,1,1)) Amd <- madogram(x, data, "emp") Amd.bp <- beed(data, x, 2, "md", "emp", 20, plot=TRUE) lines(x[,1], Amd, lty = 1, col = 2)
x <- simplex(2) data <- evd::rbvevd(50, dep = 0.4, model = "log", mar1 = c(1,1,1)) Amd <- madogram(x, data, "emp") Amd.bp <- beed(data, x, 2, "md", "emp", 20, plot=TRUE) lines(x[,1], Amd, lty = 1, col = 2)
Two datasets Milan.summer
and Milan.winter
, each containing 5 air pollutants: daily maximum of NO2, NO, O3 and SO2, daily mean of PM10; and 6 meteorological covariates: maximum precipitation, maximum temperature, maximum humidity, mean precipitation, mean temperature and mean humidity.
A data frame and a
data frame.
The summer period corresponds to the period 30 April - 30 August between 2003 and 2017 and thus the dataset contains observations. The winter period corresponds to the period 32 November - 27(28) February. The records start from 31 December 2001 until 30 December 2017 and thus the dataset contains
observations.
This function evaluates the distribution function of parametric multivariate extreme distributions and the angular probability distribution represented through Bernstein polynomials.
pExtDep(q, type, method="Parametric", model, par, plot=TRUE, main, xlab, cex.lab, cex.axis, lwd,...)
pExtDep(q, type, method="Parametric", model, par, plot=TRUE, main, xlab, cex.lab, cex.axis, lwd,...)
q |
A vector or matrix of quantiles. |
type |
A character string taking value |
method |
A character string taking value |
model |
A character string with the name of the model: |
par |
A vector or a matrix representing the parameters of the (parametric or non-parametric) model. When in matrix format, rows indicate different sets of parameter values. |
plot |
A logical value; if |
main , xlab , cex.lab , cex.axis , lwd
|
Arguments of the |
... |
Additional graphical parameter when |
Note that when method="Parametric"
, the distribution function is only available in 2 and 3 dimensions. Refer to the dim_ExtDep
function for the appropriate length of the parameter vector.
When type="lower"
, the cumulative distribution function is computed, i.e.,
When type="inv.lower"
, the survival function is computed, i.e.,
This corresponds to the probability of at least one component of is greater than its corresponding element in
.
When type="upper"
, the joint probability of exceedance is computed, i.e.,
Finally, when method="NonParametric"
, the distribution function is only available in 2 dimensions.
The argument plot
is only applicable when par
is a matrix. Typically its main use should be when par
corresponds to some posterior sample (e.g. from fExtDep
with moethod="BayesianPPP"
). A histogram of the probabilities evaluated at each set of parameters is displayed, as well as a kernel density estimator, quantiles (crosses) and mean (dot). The argument
...
is used to specify additional parameters in the hist()
function.
When par
is a vector: if q
is a matrix the function returns a vector of length nrow(q)
, otherwise a scalar.
When par
is a matrix: if q
is a matrix the function returns a matrix with nrow(par)
rows and nrow(q)
columns, otherwise a vector of length nrow(par)
.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
Beranger, B. and Padoan, S. A. (2015). Extreme dependence models, chapater of the book Extreme Value Modeling and Risk Analysis: Methods and Applications, Chapman Hall/CRC.
Beranger, B., Padoan, S. A. and Sisson, S. A. (2017). Models for extremal dependence derived from skew-symmetric families. Scandinavian Journal of Statistics, 44(1), 21-45.
Husler, J. and Reiss, R.-D. (1989), Maxima of normal random vectors: between independence and complete dependence, Statistics and Probability Letters, 7, 283–286.
Marcon, G., Padoan, S.A., Naveau, P., Muliere, P. and Segers, J. (2017) Multivariate Nonparametric Estimation of the Pickands Dependence Function using Bernstein Polynomials. Journal of Statistical Planning and Inference, 183, 1-17.
dExtDep
, rExtDep
, fExtDep
, fExtDep.np
# Example using the trivariate Extremal Skew-t pExtDep(q=c(1,1.2, 0.6), type="lower", method="Parametric", model="EST", par=c(0.2, 0.4, 0.6,2,2,2,1)) # Example using the bivariate Extremal-t pExtDep(q=rbind(c(1.2, 0.6), c(1.1, 1.3)), type="inv.lower", method="Parametric", model="ET", par=c(0.2, 1)) pExtDep(q=rbind(c(1.2, 0.6), c(1.1, 1.3)), type="inv.lower", method="Parametric", model="EST", par=c(0.2, 0, 0, 1)) # Example of non-parametric angular density beta <- c(1.0000000, 0.8714286, 0.7671560, 0.7569398, 0.7771908, 0.8031573, 0.8857143, 1.0000000) pExtDep(q=rbind(c(0.1,0.9),c(0.2,0.8)), method="NonParametric", par=beta)
# Example using the trivariate Extremal Skew-t pExtDep(q=c(1,1.2, 0.6), type="lower", method="Parametric", model="EST", par=c(0.2, 0.4, 0.6,2,2,2,1)) # Example using the bivariate Extremal-t pExtDep(q=rbind(c(1.2, 0.6), c(1.1, 1.3)), type="inv.lower", method="Parametric", model="ET", par=c(0.2, 1)) pExtDep(q=rbind(c(1.2, 0.6), c(1.1, 1.3)), type="inv.lower", method="Parametric", model="EST", par=c(0.2, 0, 0, 1)) # Example of non-parametric angular density beta <- c(1.0000000, 0.8714286, 0.7671560, 0.7569398, 0.7771908, 0.8031573, 0.8857143, 1.0000000) pExtDep(q=rbind(c(0.1,0.9),c(0.2,0.8)), method="NonParametric", par=beta)
This function computes the empirical estimate of the probability of falling into two types of failure regions.
pFailure(n, beta, u1, u2, mar1, mar2, type, plot, xlab, ylab, nlevels=10)
pFailure(n, beta, u1, u2, mar1, mar2, type, plot, xlab, ylab, nlevels=10)
n |
An integer indicating the number of points generated to compute the empirical probability. |
beta |
A vector representing the Bernstein polynomial coefficients. |
u1 , u2
|
Vectors of positive reals representing some high thresholds. |
mar1 , mar2
|
Vectors of marginal (GEV) parameters |
type |
A character string indicating if the failure region includes at least one exceedance ( |
plot |
A logical value; if |
xlab , ylab
|
A character string equivalent representing the graphical parameters as in |
nlevels |
The number of contour levels to be displayed. |
The two failure regions are:
and
where and
.
Exceedances samples and
are generating according to Algorithm 3 of Marcon et al. (2017) and the the estimates of the probability of falling in
and
are given by
and
A list containing AND
and/or OR
, depending on the type
argument. Each element is a length(u1) x length(u2)
matrix.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
Marcon, G., Naveau, P. and Padoan, S.A. (2017) A semi-parametric stochastic generator for bivariate extreme events Stat, 6, 184-201.
dExtDep
, rExtDep
, fExtDep
, fExtDep.np
# Example wind speed and wind gust data(WindSpeedGust) years <- format(ParcayMeslay$time, format="%Y") attach(ParcayMeslay[which(years %in% c(2004:2013)),]) WS_th <- quantile(WS,.9) DP_th <- quantile(DP,.9) pars.WS <- evd::fpot(WS, WS_th, model="pp")$estimate pars.DP <- evd::fpot(DP, DP_th, model="pp")$estimate data_uf <- trans2UFrechet(cbind(WS,DP), type="Empirical") rdata <- rowSums(data_uf) r0 <- quantile(rdata, probs=.90) extdata <- data_uf[rdata>=r0,] SP_mle <- fExtDep.np(method="Frequentist", data=extdata, k0=10, type="maxima") pF <- pFailure(n=50000, beta=SP_mle$Ahat$beta, u1=seq(from=19, to=28, length=200), mar1=pars.WS, u2=seq(from=40, to=60, length=200), mar2=pars.DP, type="both", plot=TRUE, xlab="Daily-maximum Wind Speed (m/s)", ylab="Differential of Pressure (mbar)", nlevels=15)
# Example wind speed and wind gust data(WindSpeedGust) years <- format(ParcayMeslay$time, format="%Y") attach(ParcayMeslay[which(years %in% c(2004:2013)),]) WS_th <- quantile(WS,.9) DP_th <- quantile(DP,.9) pars.WS <- evd::fpot(WS, WS_th, model="pp")$estimate pars.DP <- evd::fpot(DP, DP_th, model="pp")$estimate data_uf <- trans2UFrechet(cbind(WS,DP), type="Empirical") rdata <- rowSums(data_uf) r0 <- quantile(rdata, probs=.90) extdata <- data_uf[rdata>=r0,] SP_mle <- fExtDep.np(method="Frequentist", data=extdata, k0=10, type="maxima") pF <- pFailure(n=50000, beta=SP_mle$Ahat$beta, u1=seq(from=19, to=28, length=200), mar1=pars.WS, u2=seq(from=40, to=60, length=200), mar2=pars.DP, type="both", plot=TRUE, xlab="Daily-maximum Wind Speed (m/s)", ylab="Differential of Pressure (mbar)", nlevels=15)
This function displays the angular density, Pickands dependence function and return levels for bivariate and trivariate extreme values models.
plot_ExtDep(object="angular", model, par, log=TRUE, data=NULL, contour=TRUE, style, labels, cex.dat=1, cex.lab=1, cex.cont=1, Q.fix, Q.range, Q.range0, cond=FALSE, ...)
plot_ExtDep(object="angular", model, par, log=TRUE, data=NULL, contour=TRUE, style, labels, cex.dat=1, cex.lab=1, cex.cont=1, Q.fix, Q.range, Q.range0, cond=FALSE, ...)
object |
A character string indicating which graphical summary to plot. Takes value |
model |
A string with the name of the model considered. Takes value |
par |
A vector representing the parameters of the model. |
log |
A logical value specifying if the log density is computed. Required when |
data |
A matrix representing angular data to be added to the density plot. Required when |
contour |
A logical value; if |
style |
A character string indicating the plotting style of the data. Takes value |
labels |
A vector of character strings indicating the labels. Must be of length |
cex.dat |
A positive real indicating the size of the data points. Required for the trivariate angular density. |
cex.lab |
A positive real indicating the size of the labels. |
cex.cont |
A positive real indicating the size of the contour labels. |
Q.fix |
A vector of length the dimension of the model, indicating some fixed quantiles to compute joint return levels. Must contain |
Q.range |
A vector or matrix indicating quantile values on the unit Frechet scale, for the components that are allowed to vary. Must be a vector or a one-column matrix if there is one |
Q.range0 |
A object of the same format as |
cond |
A logical value; if |
... |
Additional graphical arguments for the |
The angular density is computed using the function dExtDep
with arguments method="Parametric"
and angular=TRUE
. The Pickands dependence function is computed using the function index.ExtDep
with argument object="pickands"
.
When displaying the bivariate angular density and some data are provided (a 2-column matrix is specified for data
), there is the choice to summarise the data using a histogram (style="hist"
) or to display the observations using tick marks (style="ticks"
).
When displaying return levels, there are two possibilities: univariate and bivariate return levels. Since the model dimensions are restricted to a maximum of three, in that case, aunivariate return level corresponds to fixing two components while a bivariate return level fixes only one component. The choice of the fixed component is decided by the position of the NA
value(s) in the Q.fix
argument. If par
is a vector then the corresponding return level(s) are printed. However if par
is a matrix then the return level(s) are evaluated for each value of the parameter vector and the mean, and empirical empirical interval are displayed. Typically this is used when posterior samples are available. When
par
is a matrix with only two rows, resulting plots may not provide much information.
When contours are displayed, levels are chosen to be the deciles.
A graph depending on argument object
.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
data(pollution) ############################### ### Trivariate Husler-Reiss ### ############################### f.hr <- fExtDep(method="PPP", data=PNS, model="HR", par.start=rep(1,3)) plot_ExtDep(object="angular", model="HR", par=f.hr$par, data=PNS, labels=c(expression(PM[10]), expression(NO), expression(SO[2])), cex.lab=2) plot_ExtDep(object="pickands", model="HR", par=f.hr$par, data=PNS, labels=c(expression(PM[10]), expression(NO), expression(SO[2])), cex.lab=2) # Takes time! ############################### ### Bivariate Husler-Reiss ### ############################### PN <- na.omit(Leeds.frechet[,1:2]) PN <- cbind(PN, rowSums(PN)) PN <- PN[order(PN[,3], decreasing = TRUE)[1:100],] PN <- PN[,1:2]/PN[,3] f.hr2 <- fExtDep(method="PPP", data=PN, model = "HR", par.start = 1) plot_ExtDep(model="HR", par=f.hr2$par, log=FALSE, data=PN, style="hist") plot_ExtDep(model="HR", par=f.hr2$par, log=FALSE, data=PN, style="ticks") plot_ExtDep(object="pickands", model="HR", par=f.hr2$par)
data(pollution) ############################### ### Trivariate Husler-Reiss ### ############################### f.hr <- fExtDep(method="PPP", data=PNS, model="HR", par.start=rep(1,3)) plot_ExtDep(object="angular", model="HR", par=f.hr$par, data=PNS, labels=c(expression(PM[10]), expression(NO), expression(SO[2])), cex.lab=2) plot_ExtDep(object="pickands", model="HR", par=f.hr$par, data=PNS, labels=c(expression(PM[10]), expression(NO), expression(SO[2])), cex.lab=2) # Takes time! ############################### ### Bivariate Husler-Reiss ### ############################### PN <- na.omit(Leeds.frechet[,1:2]) PN <- cbind(PN, rowSums(PN)) PN <- PN[order(PN[,3], decreasing = TRUE)[1:100],] PN <- PN[,1:2]/PN[,3] f.hr2 <- fExtDep(method="PPP", data=PN, model = "HR", par.start = 1) plot_ExtDep(model="HR", par=f.hr2$par, log=FALSE, data=PN, style="hist") plot_ExtDep(model="HR", par=f.hr2$par, log=FALSE, data=PN, style="ticks") plot_ExtDep(object="pickands", model="HR", par=f.hr2$par)
This function displays several summaries of extremal dependence represented through Bernstein polynomials.
plot_ExtDep.np(out, type, summary.mcmc, burn, y, probs, A_true, h_true, est.out, mar1, mar2, dep, QatCov1=NULL, QatCov2=QatCov1, P, labels=c(expression(y[1]),expression(y[2])), CEX=1.5, xlim, ylim, col.data, col.Qfull, col.Qfade, data=NULL, ...)
plot_ExtDep.np(out, type, summary.mcmc, burn, y, probs, A_true, h_true, est.out, mar1, mar2, dep, QatCov1=NULL, QatCov2=QatCov1, P, labels=c(expression(y[1]),expression(y[2])), CEX=1.5, xlim, ylim, col.data, col.Qfull, col.Qfade, data=NULL, ...)
out |
An output of the |
type |
A character string indicating the type of graphical summary to be plotted. Takes values |
summary.mcmc |
The output of the |
burn |
The burn-in period. Only required when |
y |
A 2-column matrix of unobserved thresholds at which the returns are calculated. Required when |
probs |
The probability of joint exceedances, the output of the |
A_true |
A vector representing the true pickands dependence function evaluated at the grid points on the simplex given by |
h_true |
A vector representing the true angular density function evaluated at the grid points on the simplex given by |
est.out |
A list containing:
Note that a posterior summary is made of its mean and Only required when using a Bayesian estimation method ( |
mar1 , mar2
|
Vectors of marginal GEV parameters. Required when |
dep |
A logical value; if |
QatCov1 , QatCov2
|
Matrices representing the value of the covariates at which extreme quantile regions should be computed. Required when |
P |
A vector indicating the probabilities associated with the quantiles to be computed. Required when |
labels |
A bivariate vector of character strings providing labels for extreme quantile regions. Required when |
CEX |
Label and axis sizes. |
xlim , ylim
|
Limits of the x and y axis when computing extreme quantile regions. Required when |
col.data , col.Qfull , col.Qfade
|
Colors for data, estimate of extreme quantile regions and its credible interval (when applicable). Required when |
data |
A 2-column matrix providing the original data to be plotted when |
... |
Additional graphical parameters |
If type="returns"
, a (contour) plot of the probabilities of exceedances for some threshold is returned. This corresponds to the output of the returns
function.
If type="A"
, a plot of the estimated Pickands dependence function is drawn. If A_true
is specified the plot includes the true Pickands dependence function and a functional boxplot for the estimated function.
If type="h"
, a plot of the estimated angular density function is drawn. If h_true
is specified the plot includes the true angular density and a functional boxplot for the estimated function.
If type="pm"
, a plot of the prior against the posterior for the mass at is drawn.
If
type="k"
, a plot of the prior against the posterior for the polynomial degree is drawn.
If
type="summary"
, when the estimation was performed in a Bayesian framework then a 2 by 2 plot with types "A"
, "h"
, "pm"
and "k"
is returned. Otherwise a 1 by 2 plot with types "A"
and "h"
is returned.
If type="Qsets"
, extreme quantile regions are computed according to the methodology developped in Beranger et al. (2021).
a graph depending on argument type
.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com; Giulia Marcon, [email protected]
Beranger, B., Padoan, S. A. and Sisson, S. A. (2021). Estimation and uncertainty quantification for extreme quantile regions. Extremes, 24, 349-375.
Marcon, G., Padoan, S.A., Naveau, P., Muliere, P., Segers, J. (2017) Multivariate Nonparametric Estimation of the Pickands Dependence Function using Bernstein Polynomials. Journal of Statistical Planning and Inference, 183, 1-17.
########################################################### ### Example 1 - Wind Speed and Differential of pressure ### ########################################################### data(WindSpeedGust) years <- format(ParcayMeslay$time, format="%Y") attach(ParcayMeslay[which(years %in% c(2004:2013)),]) # Marginal quantiles WS_th <- quantile(WS,.9) DP_th <- quantile(DP,.9) # Standardisation to unit Frechet (requires evd package) pars.WS <- evd::fpot(WS, WS_th, model="pp")$estimate pars.DP <- evd::fpot(DP, DP_th, model="pp")$estimate # transform the marginal distribution to common unit Frechet: data_uf <- trans2UFrechet(cbind(WS,DP), type="Empirical") # compute exceedances rdata <- rowSums(data_uf) r0 <- quantile(rdata, probs=.90) extdata_WSDP <- data_uf[rdata>=r0,] # Fit SP_mle <- fExtDep.np(method="Frequentist", data=extdata_WSDP, k0=10, type="maxima") # Plot plot_ExtDep.np(out=SP_mle, type="summary") #################################################### ### Example 2 - Pollution levels in Milan, Italy ### #################################################### ## Not run: ### Here we will only model the dependence structure data(MilanPollution) data <- Milan.winter[,c("NO2","SO2")] data <- as.matrix(data[complete.cases(data),]) # Thereshold u <- apply(data, 2, function(x) quantile(x, prob=0.9, type=3)) # Hyperparameters hyperparam <- list(mu.nbinom = 6, var.nbinom = 8, a.unif=0, b.unif=0.2) ### Standardise data to univariate Frechet margins f1 <- fGEV(data=data[,1], method="Bayesian", sig0 = 0.0001, nsim = 5e+4) diagnostics(f1) burn1 <- 1:30000 gev.pars1 <- apply(f1$param_post[-burn1,],2,mean) sdata1 <- trans2UFrechet(data=data[,1], pars=gev.pars1, type="GEV") f2 <- fGEV(data=data[,2], method="Bayesian", sig0 = 0.0001, nsim = 5e+4) diagnostics(f2) burn2 <- 1:30000 gev.pars2 <- apply(f2$param_post[-burn2,],2,mean) sdata2 <- trans2UFrechet(data=data[,2], pars=gev.pars2, type="GEV") sdata <- cbind(sdata1,sdata2) ### Bayesian estimation using Bernstein polynomials pollut1 <- fExtDep.np(method="Bayesian", data=sdata, u=TRUE, mar.fit=FALSE, k0=5, hyperparam = hyperparam, nsim=5e+4) diagnostics(pollut1) pollut1_sum <- summary_ExtDep(mcmc=pollut1, burn=3e+4, plot=TRUE) pl1 <- plot_ExtDep.np(out=pollut1, type="Qsets", summary.mcmc=pollut1_sum, mar1=gev.pars1, mar2=gev.pars2, P = 1/c(600, 1200, 2400), dep=TRUE, data=data, xlim=c(0,400), ylim=c(0,400)) pl1b <- plot_ExtDep.np(out=pollut1, type="Qsets", summary.mcmc=pollut1_sum, est.out=pl1$est.out, mar1=gev.pars1, mar2=gev.pars2, P = 1/c(1200), dep=FALSE, data=data, xlim=c(0,400), ylim=c(0,400)) ### Frequentist estimation using Bernstein polynomials pollut2 <- fExtDep.np(method="Frequentist", data=sdata, mar.fit=FALSE, type="rawdata", k0=8) plot_ExtDep.np(out=pollut2, type = c("summary"), CEX=1.5) pl2 <- plot_ExtDep.np(out=pollut2, type="Qsets", mar1=gev.pars1, mar2=gev.pars2, P = 1/c(600, 1200, 2400), dep=TRUE, data=data, xlim=c(0,400), ylim=c(0,400), labels=c(expression(NO[2]),expression(SO[2])), col.Qfull = c("red", "green", "blue")) ### Frequentist estimation using EKdH estimator pollut3 <- fExtDep.np(method="Empirical", data=data) plot_ExtDep.np(out=pollut3, type = c("summary"), CEX=1.5) pl3 <- plot_ExtDep.np(out=pollut3, type="Qsets", mar1=gev.pars1, mar2=gev.pars2, P = 1/c(600, 1200, 2400), dep=TRUE, data=data, xlim=c(0,400), ylim=c(0,400), labels=c(expression(NO[2]),expression(SO[2])), col.Qfull = c("red", "green", "blue")) ## End(Not run)
########################################################### ### Example 1 - Wind Speed and Differential of pressure ### ########################################################### data(WindSpeedGust) years <- format(ParcayMeslay$time, format="%Y") attach(ParcayMeslay[which(years %in% c(2004:2013)),]) # Marginal quantiles WS_th <- quantile(WS,.9) DP_th <- quantile(DP,.9) # Standardisation to unit Frechet (requires evd package) pars.WS <- evd::fpot(WS, WS_th, model="pp")$estimate pars.DP <- evd::fpot(DP, DP_th, model="pp")$estimate # transform the marginal distribution to common unit Frechet: data_uf <- trans2UFrechet(cbind(WS,DP), type="Empirical") # compute exceedances rdata <- rowSums(data_uf) r0 <- quantile(rdata, probs=.90) extdata_WSDP <- data_uf[rdata>=r0,] # Fit SP_mle <- fExtDep.np(method="Frequentist", data=extdata_WSDP, k0=10, type="maxima") # Plot plot_ExtDep.np(out=SP_mle, type="summary") #################################################### ### Example 2 - Pollution levels in Milan, Italy ### #################################################### ## Not run: ### Here we will only model the dependence structure data(MilanPollution) data <- Milan.winter[,c("NO2","SO2")] data <- as.matrix(data[complete.cases(data),]) # Thereshold u <- apply(data, 2, function(x) quantile(x, prob=0.9, type=3)) # Hyperparameters hyperparam <- list(mu.nbinom = 6, var.nbinom = 8, a.unif=0, b.unif=0.2) ### Standardise data to univariate Frechet margins f1 <- fGEV(data=data[,1], method="Bayesian", sig0 = 0.0001, nsim = 5e+4) diagnostics(f1) burn1 <- 1:30000 gev.pars1 <- apply(f1$param_post[-burn1,],2,mean) sdata1 <- trans2UFrechet(data=data[,1], pars=gev.pars1, type="GEV") f2 <- fGEV(data=data[,2], method="Bayesian", sig0 = 0.0001, nsim = 5e+4) diagnostics(f2) burn2 <- 1:30000 gev.pars2 <- apply(f2$param_post[-burn2,],2,mean) sdata2 <- trans2UFrechet(data=data[,2], pars=gev.pars2, type="GEV") sdata <- cbind(sdata1,sdata2) ### Bayesian estimation using Bernstein polynomials pollut1 <- fExtDep.np(method="Bayesian", data=sdata, u=TRUE, mar.fit=FALSE, k0=5, hyperparam = hyperparam, nsim=5e+4) diagnostics(pollut1) pollut1_sum <- summary_ExtDep(mcmc=pollut1, burn=3e+4, plot=TRUE) pl1 <- plot_ExtDep.np(out=pollut1, type="Qsets", summary.mcmc=pollut1_sum, mar1=gev.pars1, mar2=gev.pars2, P = 1/c(600, 1200, 2400), dep=TRUE, data=data, xlim=c(0,400), ylim=c(0,400)) pl1b <- plot_ExtDep.np(out=pollut1, type="Qsets", summary.mcmc=pollut1_sum, est.out=pl1$est.out, mar1=gev.pars1, mar2=gev.pars2, P = 1/c(1200), dep=FALSE, data=data, xlim=c(0,400), ylim=c(0,400)) ### Frequentist estimation using Bernstein polynomials pollut2 <- fExtDep.np(method="Frequentist", data=sdata, mar.fit=FALSE, type="rawdata", k0=8) plot_ExtDep.np(out=pollut2, type = c("summary"), CEX=1.5) pl2 <- plot_ExtDep.np(out=pollut2, type="Qsets", mar1=gev.pars1, mar2=gev.pars2, P = 1/c(600, 1200, 2400), dep=TRUE, data=data, xlim=c(0,400), ylim=c(0,400), labels=c(expression(NO[2]),expression(SO[2])), col.Qfull = c("red", "green", "blue")) ### Frequentist estimation using EKdH estimator pollut3 <- fExtDep.np(method="Empirical", data=data) plot_ExtDep.np(out=pollut3, type = c("summary"), CEX=1.5) pl3 <- plot_ExtDep.np(out=pollut3, type="Qsets", mar1=gev.pars1, mar2=gev.pars2, P = 1/c(600, 1200, 2400), dep=TRUE, data=data, xlim=c(0,400), ylim=c(0,400), labels=c(expression(NO[2]),expression(SO[2])), col.Qfull = c("red", "green", "blue")) ## End(Not run)
Contains datasets:
PNS
, PNN
, NSN
, PNNS
,
winterdat
and Leeds.frechet
.
The dataset winterdat
contains (transformed) observations for
each of the five pollutants. Contains
NA
s.
Outliers have been removed according to Heffernan and Tawn (2004).
The following datasets have been obtained by applying transformations to winterdat
.
Leeds.frechet
contains observations corresponding to the
daily maxima of five air pollutants transformed to unit Frechet scale.
NSN
contains observations in the
-dimensional
unit simplex for the daily maxima of nitrogen dioxide (NO2), sulfur dioxide (SO2)
and nitrogen oxide (NO).
PNN
contains observations in the
-dimensional
unit simplex for the daily maxima of particulate matter (PM10), nitrogen oxide (NO)
and nitrogen dioxide (NO2).
PNS
contains observations in the
-dimensional
unit simplex for the daily maxima of particulate matter (PM10), nitrogen oxide (NO)
and sulfur dioxide (SO2).
PNNS
contains observations in the
-dimensional
unit simplex for the daily maxima of particulate matter (PM10), nitrogen oxide (NO),
nitrogen dioxide (NO2) and sulfur dioxide (S02).
The transformation to unit Frechet margins of the raw data has been considered by
Cooley et al (2010). Only the data points with the largest radial components
were kept.
Cooley, D.,Davis, R. A., and Naveau, P. (2010). The pairwise beta distribution: a flexible parametric multivariate model for extremes. Journal of Multivariate Analysis, 101, 2103–2117.
Heffernan, J. E., and Tawn, J. A. (2004). A conditional approach for multivariate extreme values. Journal of the Royal Statistical Society, Series B, Methodology, 66, 497–546
List containing the weekly maxima of hourly rainfall in the Fall season from 1993 to 2011 recorded at 92 stations across France (precip
). Coordinates of the monitoring stations are given in lat
and lon
.
A list made of a matrix (
precip
) and two vectors of length (
lat
and lon
).
The fall season corresponds to the September-November (SON) period. The data thus cover a 12-week period over years, yielding a sample of
observations (rows) and
stations (columns).
Predicts the probability of future simultaneous exceedances
returns(out, summary.mcmc, y, plot=FALSE, labels=NULL, data=NULL)
returns(out, summary.mcmc, y, plot=FALSE, labels=NULL, data=NULL)
out |
The output of the |
summary.mcmc |
The output of the |
y |
A 2-column matrix of unobserved thresholds. |
plot |
A logical value; if |
labels |
As in |
data |
As in |
Computes for a range of unobserved extremes (larger than those observed in a sample), the pointwise mean from the posterior predictive distribution of such predictive values. The probabilities are calculated through
where denotes the cumulative distribution function of a Beta random variable with shape
. See Marcon et al. (2016, p.3323) for details.
Returns a vector whose length is equal to the number of rows of the input value y
.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com; Giulia Marcon, [email protected]
Marcon, G., Padoan, S. A. and Antoniano-Villalobos, I. (2016). Bayesian inference for the extremal dependence. Electronic Journal of Statistics, 10, 3310-3337.
######################################################### ### Example 1 - daily log-returns between the GBP/USD ### ### and GBP/JPY exchange rates ### ######################################################### if(interactive()){ data(logReturns) mm_gbp_usd <- ts(logReturns$USD, start=c(1991,3), end=c(2014,12), frequency=12) mm_gbp_jpy <- ts(logReturns$JPY, start=c(1991,3), end=c(2014,12), frequency=12) ### Detect seasonality and trend in the time series of maxima: seas_usd <- stl(mm_gbp_usd, s.window="period") seas_jpy <- stl(mm_gbp_jpy, s.window="period") ### remove the seasonality and trend from the two series: mm_gbp_usd_filt <- mm_gbp_usd - rowSums(seas_usd$time.series[,-3]) mm_gbp_jpy_filt <- mm_gbp_jpy - rowSums(seas_jpy$time.series[,-3]) ### Estimation of margins and dependence mm_gbp <- cbind(as.vector(mm_gbp_usd_filt), as.vector(mm_gbp_jpy_filt)) hyperparam <- list(mu.nbinom = 3.2, var.nbinom = 4.48) gbp_mar <- fExtDep.np(method="Bayesian", data=mm_gbp, par10=rep(0.1, 3), par20=rep(0.1,3), sig10=0.0001, sig20=0.0001, k0=5, hyperparam = hyperparam, nsim=5e+4) gbp_mar_sum <- summary_ExtDep(mcmc=gbp_mar, burn=3e+4, plot=TRUE) mm_gbp_range <- apply(mm_gbp,2,quantile,c(0.9,0.995)) y_gbp_usd <- seq(from=mm_gbp_range[1,1], to=mm_gbp_range[2,1], length=20) y_gbp_jpy <- seq(from=mm_gbp_range[1,2], to=mm_gbp_range[2,2], length=20) y <- as.matrix(expand.grid(y_gbp_usd, y_gbp_jpy, KEEP.OUT.ATTRS = FALSE)) ret_marg <- returns(out=gbp_mar, summary.mcmc=gbp_mar_sum, y=y, plot=TRUE, data=mm_gbp, labels=c("GBP/USD exchange rate", "GBP/JPY exchange rate")) } ######################################################### ### Example 2 - Reproducing some of the results shown ### ### in Marcon et al. (2016, Figure 1) ### ######################################################### ## Not run: set.seed(1890) data <- evd::rbvevd(n=100, dep=0.6, asy=c(0.8,0.3), model="alog", mar1=c(1,1,1)) hyperparam <- list(a.unif=0, b.unif=.5, mu.nbinom=3.2, var.nbinom=4.48) pm0 <- list(p0=0.06573614, p1=0.3752118) mcmc <- fExtDep.np(method="Bayesian", data=data, mar.fit=FALSE, k0=5, pm0=pm0, prior.k = "nbinom", prior.pm = "unif", hyperparam=hyperparam, nsim=5e+5) w <- seq(0.001, 0.999, length=100) summary.mcmc <- summary_ExtDep(w, mcmc, burn=4e+5, plot=TRUE) plot_ExtDep.np(out=mcmc, type = "A", summary.mcmc=summary.mcmc) plot_ExtDep.np(out=mcmc, type = "h", summary.mcmc=summary.mcmc) plot_ExtDep.np(out=mcmc, type = "pm", summary.mcmc=summary.mcmc) plot_ExtDep.np(out=mcmc, type = "k", summary.mcmc=summary.mcmc) y <- seq(10,100,2) y <- as.matrix(expand.grid(y,y)) probs <- returns(out=mcmc, summary.mcmc=summary.mcmc, y=y, plot=TRUE) ## End(Not run)
######################################################### ### Example 1 - daily log-returns between the GBP/USD ### ### and GBP/JPY exchange rates ### ######################################################### if(interactive()){ data(logReturns) mm_gbp_usd <- ts(logReturns$USD, start=c(1991,3), end=c(2014,12), frequency=12) mm_gbp_jpy <- ts(logReturns$JPY, start=c(1991,3), end=c(2014,12), frequency=12) ### Detect seasonality and trend in the time series of maxima: seas_usd <- stl(mm_gbp_usd, s.window="period") seas_jpy <- stl(mm_gbp_jpy, s.window="period") ### remove the seasonality and trend from the two series: mm_gbp_usd_filt <- mm_gbp_usd - rowSums(seas_usd$time.series[,-3]) mm_gbp_jpy_filt <- mm_gbp_jpy - rowSums(seas_jpy$time.series[,-3]) ### Estimation of margins and dependence mm_gbp <- cbind(as.vector(mm_gbp_usd_filt), as.vector(mm_gbp_jpy_filt)) hyperparam <- list(mu.nbinom = 3.2, var.nbinom = 4.48) gbp_mar <- fExtDep.np(method="Bayesian", data=mm_gbp, par10=rep(0.1, 3), par20=rep(0.1,3), sig10=0.0001, sig20=0.0001, k0=5, hyperparam = hyperparam, nsim=5e+4) gbp_mar_sum <- summary_ExtDep(mcmc=gbp_mar, burn=3e+4, plot=TRUE) mm_gbp_range <- apply(mm_gbp,2,quantile,c(0.9,0.995)) y_gbp_usd <- seq(from=mm_gbp_range[1,1], to=mm_gbp_range[2,1], length=20) y_gbp_jpy <- seq(from=mm_gbp_range[1,2], to=mm_gbp_range[2,2], length=20) y <- as.matrix(expand.grid(y_gbp_usd, y_gbp_jpy, KEEP.OUT.ATTRS = FALSE)) ret_marg <- returns(out=gbp_mar, summary.mcmc=gbp_mar_sum, y=y, plot=TRUE, data=mm_gbp, labels=c("GBP/USD exchange rate", "GBP/JPY exchange rate")) } ######################################################### ### Example 2 - Reproducing some of the results shown ### ### in Marcon et al. (2016, Figure 1) ### ######################################################### ## Not run: set.seed(1890) data <- evd::rbvevd(n=100, dep=0.6, asy=c(0.8,0.3), model="alog", mar1=c(1,1,1)) hyperparam <- list(a.unif=0, b.unif=.5, mu.nbinom=3.2, var.nbinom=4.48) pm0 <- list(p0=0.06573614, p1=0.3752118) mcmc <- fExtDep.np(method="Bayesian", data=data, mar.fit=FALSE, k0=5, pm0=pm0, prior.k = "nbinom", prior.pm = "unif", hyperparam=hyperparam, nsim=5e+5) w <- seq(0.001, 0.999, length=100) summary.mcmc <- summary_ExtDep(w, mcmc, burn=4e+5, plot=TRUE) plot_ExtDep.np(out=mcmc, type = "A", summary.mcmc=summary.mcmc) plot_ExtDep.np(out=mcmc, type = "h", summary.mcmc=summary.mcmc) plot_ExtDep.np(out=mcmc, type = "pm", summary.mcmc=summary.mcmc) plot_ExtDep.np(out=mcmc, type = "k", summary.mcmc=summary.mcmc) y <- seq(10,100,2) y <- as.matrix(expand.grid(y,y)) probs <- returns(out=mcmc, summary.mcmc=summary.mcmc, y=y, plot=TRUE) ## End(Not run)
This function generates random samples of iid observations from extremal dependence models and semi-parametric stochastic generators.
rExtDep(n, model, par, angular=FALSE, mar=c(1,1,1), num, threshold, exceed.type)
rExtDep(n, model, par, angular=FALSE, mar=c(1,1,1), num, threshold, exceed.type)
n |
An integer indictaing the number of observations. |
model |
A character string with the name of the model. Parametric model include |
par |
A vector representing the parameters of the (parametric or non-parametric) model. |
angular |
A logical value; |
mar |
A vector or matrix of marginal parameters. |
num |
An integer indicating the number of observations the componentwise maxima is computed over. Required when |
threshold |
A bivariate vector indicating the level of exceedances. Required when |
exceed.type |
A character string taking value "and" or "or" indicating the type of exceednaces. Required when |
There is no limit of the dimensionality when model="HR"
, "ET"
or "EST"
while model="semi.bvevd"
and "semi.bvexceed"
can only generate bivariate observations.
When angular=TRUE
and model="semi.bvevd"
or "semi.bvexceed"
the simulation of pseudo-angles follows Algorithm 1 of Marcon et al. (2017).
When model="semi.bvevd"
and angular=FALSE
, maxima samples are generated according to Algorithm 2 of Marcon et al. (2017).
When model="semi.bvexceed"
and angular=FALSE
, exceedance samples are generated above value specified by threshold
, according to Algorithm 3 of Marcon et al. (2017). exceed.type="and"
generates samples that exceed both thresholds while exceed.type="or"
generates samples exceeding at least one threshold.
When the argument mar
is a vector, the marginal distrutions are identical. When a matrix is provided each row corresponds to a set of marginal parameters. No marginal transformation is applied when mar=c(1,1,1)
.
A matrix with rows and
columns.
when
model="semi.bvevd"
or "semi.bvexceed"
.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
Marcon, G., Naveau, P. and Padoan, S.A. (2017) A semi-parametric stochastic generator for bivariate extreme events Stat, 6, 184-201.
dExtDep
, pExtDep
, fExtDep
, fExtDep.np
# Example using the trivariate Husler-Reiss set.seed(1) data <- rExtDep(n=10, model="HR", par=c(2,3,3)) # Example using the semi-parammetric generator of maxima set.seed(2) beta <- c(1.0000000, 0.8714286, 0.7671560, 0.7569398, 0.7771908, 0.8031573, 0.8857143, 1.0000000) data <- rExtDep(n=10, model="semi.bvevd", par=beta, mar=rbind(c(0.2, 1.5, 0.6),c(-0.5, 0.4, 0.9))) # Example using the semi-parammetric generator of maxima set.seed(3) data <- rExtDep(n=10, model="semi.bvexceed", par=beta, threshold=c(0.2, 0.4), exceed.type="and")
# Example using the trivariate Husler-Reiss set.seed(1) data <- rExtDep(n=10, model="HR", par=c(2,3,3)) # Example using the semi-parammetric generator of maxima set.seed(2) beta <- c(1.0000000, 0.8714286, 0.7671560, 0.7569398, 0.7771908, 0.8031573, 0.8857143, 1.0000000) data <- rExtDep(n=10, model="semi.bvevd", par=beta, mar=rbind(c(0.2, 1.5, 0.6),c(-0.5, 0.4, 0.9))) # Example using the semi-parammetric generator of maxima set.seed(3) data <- rExtDep(n=10, model="semi.bvexceed", par=beta, threshold=c(0.2, 0.4), exceed.type="and")
This function generates realisations from a max-stable process.
rExtDepSpat(n, coord, model="SCH", cov.mod = "whitmat", grid = FALSE, control = list(), cholsky = TRUE, ...)
rExtDepSpat(n, coord, model="SCH", cov.mod = "whitmat", grid = FALSE, control = list(), cholsky = TRUE, ...)
n |
An integer indictaing the number of observations. |
coord |
A vector or matrix corresponding to the coordinates of locations where the processes is simulated. Each row corresponds to a location. |
model |
A character string indicating the max-stable model. See |
cov.mod |
A character string indicating the correlation function function. See |
grid |
A logical value; |
control |
A named list with arguments |
cholsky |
A logical value; if |
... |
The parameters of the max-stable model. See |
This function extends the rmaxstab
function from the SpatialExtremes
package in two ways:
The extremal skew-t model is included.
The function returns the hitting scenarios, i.e. the index of which 'storm' (or process) led to the maximum value for each location and observation.
The max-stable models available in this procedure and the specifics are:
when model='SMI'
, does not require cov.mod
. If coord
is univariate then var
needs to be specified and for higher dimensions covariance parameters should be provided such as cov11
, cov12
, cov22
, etc.
when model='SCH'
, requires cov.mod='whitmat'
, 'cauchy'
, 'powexp'
or 'bessel'
depending on the correlation family. Parameters 'nugget'
, 'range'
and 'smooth'
should be specified.
when model='ET'
, requires cov.mod='whitmat'
, 'cauchy'
, 'powexp'
or 'bessel'
depending on the correlation family. Parameters 'nugget'
, 'range'
, 'smooth'
and 'DoF'
should be specified.
when model='EST'
, requires cov.mod='whitmat'
, 'cauchy'
, 'powexp'
or 'bessel'
depending on the correlation family. Parameters 'nugget'
, 'range'
, 'smooth'
, 'DoF'
, 'alpha'
(a vector of length ) and
'acov1'
and 'acov2'
(both vector of length the number of locations) should be specified. The skewness vector is defined as .
when model='GG'
, requires cov.mod='whitmat'
, 'cauchy'
, 'powexp'
or 'bessel'
depending on the correlation family. Parameters 'sig2'
, 'nugget'
, 'range'
and 'smooth'
should be specified.
when model='BR'
, does not require cov.mod
. Parameters 'range'
and 'smooth'
should be specified.
For the argument control
, details of the list components are as follows:
is NULL
by default, meaning that the function tries to find the most appropriate simulation technique. Current simulation techniques are a direct approach, i.e. Cholesky decomposition of the covariance matrix, the turning bands and the circular embedding methods. Note that for the extremal skew-t model it can only take value 'exact'
or 'direct'
;
if NULL
then it is set to ;
if NULL
then it is set to reasonable values - for example for the Schlather model.
A list made of
A matrix containing
observations at
locations, from the specified max-stable model.
A matrix containing the hitting scenarios for each observations. On each row, elements with the same integer value indicate that the maxima at these two locations is coming from the same 'storm' or process.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
Beranger, B., Stephenson, A. G. and Sisson, S.A. (2021) High-dimensional inference using the extremal skew-t process Extremes, 24, 653-685.
# Generate some locations set.seed(1) lat <- lon <- seq(from=-5, to=5, length=20) sites <- as.matrix(expand.grid(lat,lon)) # Example using the extremal-t set.seed(2) z <- rExtDepSpat(1, sites, model="ET", cov.mod="powexp", DoF=1, nugget=0, range=3, smooth=1.5, control=list(method="exact")) fields::image.plot(lat, lon, matrix(z$vals,ncol=20) ) # Example using the extremal skew-t set.seed(3) z2 <- rExtDepSpat(1, sites, model="EST", cov.mod="powexp", DoF=5, nugget=0, range=3, smooth=1.5, alpha=c(0,5,5), acov1=sites[,1], acov2=sites[,2], control=list(method="exact")) fields::image.plot(lat, lon, matrix(z2$vals,ncol=20) )
# Generate some locations set.seed(1) lat <- lon <- seq(from=-5, to=5, length=20) sites <- as.matrix(expand.grid(lat,lon)) # Example using the extremal-t set.seed(2) z <- rExtDepSpat(1, sites, model="ET", cov.mod="powexp", DoF=1, nugget=0, range=3, smooth=1.5, control=list(method="exact")) fields::image.plot(lat, lon, matrix(z$vals,ncol=20) ) # Example using the extremal skew-t set.seed(3) z2 <- rExtDepSpat(1, sites, model="EST", cov.mod="powexp", DoF=5, nugget=0, range=3, smooth=1.5, alpha=c(0,5,5), acov1=sites[,1], acov2=sites[,2], control=list(method="exact")) fields::image.plot(lat, lon, matrix(z2$vals,ncol=20) )
Generation of grid points over the multivariate simplex
simplex(d, n=50, a=0, b=1)
simplex(d, n=50, a=0, b=1)
d |
A positive integer indicating the dimension of the simplex. |
n |
A positive integer indicating the number of grid points to be generated on the univariate components of the simplex. |
a , b
|
Two numeric values indicating the lower and upper bound of the simplex. By default |
A -dimensional simplex is defined by
Here the function defines the simplex as
When d=2
and , a grid of points of the form
.
Returns a matrix with columns. When
d=2
, the number of rows is .
When
d>2
, the number of rows is equal to
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
### 3-dimensional unit simplex W <- simplex(d=3, n=10) plot(W[,-3], pch=16)
### 3-dimensional unit simplex W <- simplex(d=3, n=10) plot(W[,-3], pch=16)
This function computes summaries on the posterior sample obtained from the adaptive MCMC scheme for the non-parametric estimation of a bivariate dependence structure.
summary_ExtDep(object, mcmc, burn, cred=0.95, plot=FALSE, ...)
summary_ExtDep(object, mcmc, burn, cred=0.95, plot=FALSE, ...)
object |
A vector of values on |
mcmc |
An output of the |
burn |
A positive integer indicating the burn-in period. |
cred |
A value in |
plot |
A logical value; if |
... |
Additional graphical parameters for |
For each value say given, the complement
is automatically computed to define the observation
on the bivariate unit simplex.
It is obvious that the value of burn
must be greater than the number of iterations in the mcmc algorithm. This can be found in mcmc
.
The function returns a list with the following objects:
Posterior median, upper and lower bounds of the CI for the estimated Bernstein polynomial degree ;
Posterior mean, upper and lower bounds of the CI for the estimated angular density ;
Posterior mean, upper and lower bounds of the CI for the estimated Pickands dependence function ;
Posterior mean, upper and lower bounds of the CI for the estimated point mass ;
Posterior mean, upper and lower bounds of the CI for the estimated point mass ;
Posterior sample for Pickands dependence function;
Posterior sample for angular density;
Posterior sample for the Bernstein polynomial coefficients ( parametrisation);
Posterior sample for the Bernstein polynomial coefficients ( parametrisation);
Posterior sample for point masses and
;
A vector of values on the bivariate simplex where the angular density and Pickands dependence function were evaluated;
The argument provided;
If the margins were also fitted, the list given as object
would contain mar1
and mar2
and the function would also output:
Posterior mean, upper and lower bounds of the CI for the estimated marginal parameter on the first component;
Posterior mean, upper and lower bounds of the CI for the estimated marginal parameter on the second component;
Posterior sample for the estimated marginal parameter on the first component;
Posterior sample for the estimated marginal parameter on the second component;
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com
#################################################### ### Example - Pollution levels in Milan, Italy ### #################################################### ## Not run: ### Here we will only model the dependence structure data(MilanPollution) data <- Milan.winter[,c("NO2","SO2")] data <- as.matrix(data[complete.cases(data),]) # Thereshold u <- apply(data, 2, function(x) quantile(x, prob=0.9, type=3)) # Hyperparameters hyperparam <- list(mu.nbinom = 6, var.nbinom = 8, a.unif=0, b.unif=0.2) ### Standardise data to univariate Frechet margins f1 <- fGEV(data=data[,1], method="Bayesian", sig0 = 0.0001, nsim = 5e+4) diagnostics(f1) burn1 <- 1:30000 gev.pars1 <- apply(f1$param_post[-burn1,],2,mean) sdata1 <- trans2UFrechet(data=data[,1], pars=gev.pars1, type="GEV") f2 <- fGEV(data=data[,2], method="Bayesian", sig0 = 0.0001, nsim = 5e+4) diagnostics(f2) burn2 <- 1:30000 gev.pars2 <- apply(f2$param_post[-burn2,],2,mean) sdata2 <- trans2UFrechet(data=data[,2], pars=gev.pars2, type="GEV") sdata <- cbind(sdata1,sdata2) ### Bayesian estimation using Bernstein polynomials pollut1 <- fExtDep.np(method="Bayesian", data=sdata, u=TRUE, mar.fit=FALSE, k0=5, hyperparam = hyperparam, nsim=5e+4) diagnostics(pollut1) pollut1_sum <- summary_ExtDep(mcmc=pollut1, burn=3e+4, plot=TRUE) ## End(Not run)
#################################################### ### Example - Pollution levels in Milan, Italy ### #################################################### ## Not run: ### Here we will only model the dependence structure data(MilanPollution) data <- Milan.winter[,c("NO2","SO2")] data <- as.matrix(data[complete.cases(data),]) # Thereshold u <- apply(data, 2, function(x) quantile(x, prob=0.9, type=3)) # Hyperparameters hyperparam <- list(mu.nbinom = 6, var.nbinom = 8, a.unif=0, b.unif=0.2) ### Standardise data to univariate Frechet margins f1 <- fGEV(data=data[,1], method="Bayesian", sig0 = 0.0001, nsim = 5e+4) diagnostics(f1) burn1 <- 1:30000 gev.pars1 <- apply(f1$param_post[-burn1,],2,mean) sdata1 <- trans2UFrechet(data=data[,1], pars=gev.pars1, type="GEV") f2 <- fGEV(data=data[,2], method="Bayesian", sig0 = 0.0001, nsim = 5e+4) diagnostics(f2) burn2 <- 1:30000 gev.pars2 <- apply(f2$param_post[-burn2,],2,mean) sdata2 <- trans2UFrechet(data=data[,2], pars=gev.pars2, type="GEV") sdata <- cbind(sdata1,sdata2) ### Bayesian estimation using Bernstein polynomials pollut1 <- fExtDep.np(method="Bayesian", data=sdata, u=TRUE, mar.fit=FALSE, k0=5, hyperparam = hyperparam, nsim=5e+4) diagnostics(pollut1) pollut1_sum <- summary_ExtDep(mcmc=pollut1, burn=3e+4, plot=TRUE) ## End(Not run)
Transformation of marginal distribution from unit Frechet to GEV
trans2GEV(data, pars)
trans2GEV(data, pars)
data |
A vector of length |
pars |
A |
The transformation function is if
, and
if
.
An object of the same format and dimensions as data
.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
data(pollution) pars <- fGEV(Leeds.frechet[,1])$est par_new <- c(2, 1.5, 0.5) data_new <- trans2GEV(Leeds.frechet[,1], pars=par_new) fGEV(data_new)
data(pollution) pars <- fGEV(Leeds.frechet[,1])$est par_new <- c(2, 1.5, 0.5) data_new <- trans2GEV(Leeds.frechet[,1], pars=par_new) fGEV(data_new)
Empirical and parametric transformation of a dataset to unit Frechet marginal distribution
trans2UFrechet(data, pars, type="Empirical")
trans2UFrechet(data, pars, type="Empirical")
data |
A vector of length |
pars |
A |
type |
A character string indicating the type of transformation. Can take value |
When type="Empirical"
, the transformation function is where
denotes the empirical cumulative distribution.
When type="GEV"
, the transformation function is if
,
if
. If the argument
pars
is missing then a GEV is fitted on the columns of data
using the fGEV
function.
An object of the same format and dimensions as data
.
Simone Padoan, [email protected], https://faculty.unibocconi.it/simonepadoan/; Boris Beranger, [email protected] https://www.borisberanger.com;
data(MilanPollution) pars <- fGEV(Milan.winter$PM10)$est pars data_uf <- trans2UFrechet(data=Milan.winter$PM10, pars=pars, type="GEV") fGEV(data_uf)$est data_uf2 <- trans2UFrechet(data=Milan.winter$PM10, type="Empirical") fGEV(data_uf2)$est
data(MilanPollution) pars <- fGEV(Milan.winter$PM10)$est pars data_uf <- trans2UFrechet(data=Milan.winter$PM10, pars=pars, type="GEV") fGEV(data_uf)$est data_uf2 <- trans2UFrechet(data=Milan.winter$PM10, type="Empirical") fGEV(data_uf2)$est
There are four datasets of weekly maximum wind speed data, for each triplet of locations: CLOU.CLAY.SALL
, CLOU.CLAY.PAUL
, CLAY.SALL.PAUL
and CLOU.SALL.PAUL
.
CLOU.CLAY.SALL
is a data.frame
object with columns and
rows.
CLOU.CLAY.PAUL
is a data.frame
object with columns and
rows.
CLAY.SALL.PAUL
is a data.frame
object with columns and
rows.
CLOU.SALL.PAUL
is a data.frame
object with columns and
rows.
Missing observations have been discarded for each triplet.
Beranger, B., Padoan, S. A. and Sisson, S. A. (2017). Models for extremal dependence derived from skew-symmetric families. Scandinavian Journal of Statistics, 44(1), 21-45.
There are three objects of type data.frame
, one for each location.
Each object has the following columns:
the hourly wind speed in metres per second (m/s);
the hourly wind gust in metres per second (m/s);
the hourly air pressure at sea level in millibars.
Specifics about each object is given below:
is a data.frame
object with rows and
columns. Measurements are recorded between January 1982 and June 2003;
is a data.frame
object with rows and
columns. Measurements are recorded between March 1982 and August 1995;
is a data.frame
object with rows and
columns. Measurements are recorded between November 1984 and July 2013.
Marcon, G., Naveau, P. and Padoan, S.A. (2017) A semi-parametric stochastic generator for bivariate extreme events Stat, 6, 184-201.