Title: | Spatial Dependencies and Indices for Extremes |
---|---|
Description: | An implementation of 1) the tail pairwise dependence matrix (TPDM) as described in Jiang & Cooley (2020) <doi:10.1175/JCLI-D-19-0413.1> 2) the extremal pattern index (EPI) as described in Szemkus & Friederichs ('Spatial patterns and indices for heatwave and droughts over Europe using a decomposition of extremal dependency'; submitted to ASCMO 2023). |
Authors: | Svenja Szemkus [aut, cre], Dan Cooley [ctb], Yuing Jiang [ctb] |
Maintainer: | Svenja Szemkus <[email protected]> |
License: | MIT + file LICENSE |
Version: | 0.1-4 |
Built: | 2025-03-02 03:18:01 UTC |
Source: | https://github.com/cran/ExtrPatt |
Estimates the extremal pattern index (EPI) from either the 'm' principle components after a PCA or left- and right expansion coefficients after an SVD. In case of a SVD, the threshold-based EPI (TEPI) can optionally be calculated.
compute.EPI(coeff, m = 1:10, q = 0.98)
compute.EPI(coeff, m = 1:10, q = 0.98)
coeff |
A list, containing the t x n dimensional principle components/expansion coefficients of TPDM. Can also be output of function 'est.tpdm'. |
m |
numeric vector: Containing the Principle Components from which EPI shall be computed (e.g. with modes = c(1:10), the EPI is calculated on first ten principle components) |
q |
Optional: A threshold for computation of TEPI |
Given the first 'm' modes of principle components u and eigenvalues after a PCA, the EPI is given as:
Given the first 'm' modes of expansion coefficients u and v and singular values e after a SVD, the EPI and TEPI are given as:
An array of length t, containing EPI. TEPI is computed if if q > 0.
Szemkus & Friederichs (2023)
data <- precipGER data.alpha2 <- to.alpha.2(data$pr) Sigma <- est.tpdm(data.alpha2,anz_cores =1) res.pca <- pca.tpdm(Sigma, data.alpha2) EPI <- compute.EPI(res.pca, m = 1:10) plot(data$date, EPI, type='l')
data <- precipGER data.alpha2 <- to.alpha.2(data$pr) Sigma <- est.tpdm(data.alpha2,anz_cores =1) res.pca <- pca.tpdm(Sigma, data.alpha2) EPI <- compute.EPI(res.pca, m = 1:10) plot(data$date, EPI, type='l')
Declustering routine, which will can be applied on radial component r in estimation of the TPDM. Subroutine of est.tpdm.
decls(x, th, k)
decls(x, th, k)
x |
Real vector |
th |
Threshold |
k |
Cluster length |
numeric vector of declustered threshold exceedances
Yuing Jiang, Dan Cooley
Jiang & Cooley (2020) <doi:10.1175/JCLI-D-19-0413.1>
Estimation of tail pairwise dependence matrix (TPDM)
Sub-Routine of est.row.tpdm. Calculates one element of the TPDM
est.tpdm(X, Y = NULL, anz_cores = 1, clust = NULL, q = 0.98) est.row.tpdm(x, Y, clust = NULL, q = 0.98) est.element.tpdm(x, y, clust = NULL, q = 0.98)
est.tpdm(X, Y = NULL, anz_cores = 1, clust = NULL, q = 0.98) est.row.tpdm(x, Y, clust = NULL, q = 0.98) est.element.tpdm(x, y, clust = NULL, q = 0.98)
X |
A t x n dimensional, numeric data-matrix with t: Number of time steps and n: Number of grid points/stations |
Y |
A t x n dimensional, numeric Data-matrix with t: Number of time steps and n: Number of grid points/stations |
anz_cores |
Number of cores for parallel computing (default:1); Be careful not to overload your computer! |
clust |
Optional: If clust = NULL, no declustering is performed. Else, declustering according to cluster-length 'clust'. |
q |
Threshold for computation of TPDM. Only data above the 'q'-quantile will be used for estimation. Choose such that 0<q<1. |
x |
Array of length t, where t is the number of time steps |
y |
Same as x |
Given a random vector X with components with
and it's radial component
and angular components
and
, the i'th,j'th element of the TPDM is estimated as:
.
Given two random vectors X and Y with components with
, and it's radial component
and angular components
, the i'th,j'th element of the cross-TPDM is estimated as:
.
An n x n matrix, containing the estimate of the TPDM
Array containing the estimate of one row of the TPDM.
Value containing the estimate of one element of the TPDM.
Jiang & Cooley (2020) <doi:10.1175/JCLI-D-19-0413.1>; Szemkus & Friederichs (2023)
data <- precipGER data.alpha2 <- to.alpha.2(data$pr) Sigma <- est.tpdm(data.alpha2,anz_cores =1)
data <- precipGER data.alpha2 <- to.alpha.2(data$pr) Sigma <- est.tpdm(data.alpha2,anz_cores =1)
Applies the inverse transformation
invTrans(v)
invTrans(v)
v |
Real, positive vector |
Transformation from real, positive vector in real vector under preservation of frechet-distribution.
Real vector, containing the result of inverse transformation function.
Yuing Jiang, Dan Cooley
Cooley & Thibaud (2019) <doi:10.1093/biomet/asz028>
Calculates principal component analysis (PCA) of given TPDM
pca.tpdm(Sigma, data)
pca.tpdm(Sigma, data)
Sigma |
A n x n data array, containing the TPDM, can be output of est.tpdm. |
data |
A t x n dimensional, numeric Data-matrix with t: Number of time steps and n: Number of grid points/stations. |
list containing
pc: The Principal Components of TPDM
basis: The Eigenvectors of TPDM
extremal.basis: The Eigenvectors of TPDM but transformed in positive reals with trans
Yuing Jiang, Dan Cooley
Jiang & Cooley (2020) <doi:10.1175/JCLI-D-19-0413.1>
Daily Precipitation at several stations in Germany
data(precipGER)
data(precipGER)
A list containing containing
pr: data-array
date: time-information
lon,lat: longitude & latitude information
Daily Precipitation Data
Daily precipitation data from several wather station in southern Germany (longitude <50) over the years 2000-2019. The data has been downloaded from opendata server of german weather service (https://opendata.dwd.de/climate_environment/CDC/observations_germany/climate/daily/kl/historical/).
Quelle: Deutscher Wetterdienst
Calculates singular value decomposition (SVD) of given cross-TPDM
svd.tpdm(Sigma, X, Y)
svd.tpdm(Sigma, X, Y)
Sigma |
A n x n data array, containing the cross-TPDM, can be output of est.tpdm. |
X |
A t x n dimensional, numeric Data-matrix with t: Number of time steps and n: Number of grid points/stations. |
Y |
Same as X but for second variable. |
List containing
pcU, pcV: The left- and right expansion coefficients of cross-TPDM
U, V: The left- and right singular Vectors of cross-TPDM
extr.U, extr.V: The left- and right singular vectors of cross-TPDM, but transformed in positive reals with trans
Performs transformation to make all of the margins follow a Frechet distribution with tail-index alpha = 2.
to.alpha.2(data, orig = NULL)
to.alpha.2(data, orig = NULL)
data |
A t x n dimensional, numeric Data-matrix with t: Number of time steps and n: Number of grid points/stations |
orig |
If known: original distribution of data (currently implemented: 'normal' or 'gamma'), else: NULL |
Data-matrix of same dimension as 'data', but in Frechet-margins with tail-index 2
Applies the transformation
trans(x)
trans(x)
x |
Real vector |
Transformation from real vector in real, positive vector under preservation of Frechet-distribution.
Real, positive vector, containing the result of transformation function.
Yuing Jiang, Dan Cooley
Cooley & Thibaud (2019) <doi:10.1093/biomet/asz028>
Handles all steps for estimation of EPI from raw-data: 1) Preprocessing into Frechet-Margins 2) Estimation of TPDM 3) Calculation of Principal Components 4) Estimation of EPI
wrapper.EPI( X, Y = NULL, q = 0.98, anz_cores = 1, clust = NULL, m = 1:10, thr_EPI = NULL )
wrapper.EPI( X, Y = NULL, q = 0.98, anz_cores = 1, clust = NULL, m = 1:10, thr_EPI = NULL )
X |
A t x n dimensional Data-matrix with t: Number of time steps and n: Number of grid points/stations |
Y |
Optional: Sames as X but for second variable: If Y!=NULL, cross-TPDM instead of TPDM and SVD instead of PCA is computed |
q |
Threshold for computation of TPDM. Only data above the 'q'-quantile will be used for estimation. Choose such that 0 < q < 1. |
anz_cores |
Number of cores for parallel computing (default: 5) |
clust |
Optional_ Uf clust = NULL, no declustering is performed. Else, declustering according to cluster-length 'clust' |
m |
Numeric vector: Containing the principal components/expansion coefficients (in case of Y!=NULL) from which the EPI shall be computed (default: modes = c(1:10), calculates the EPI on first ten principle Components) |
thr_EPI |
Only if Y!=NULL: Threshold for computation of TEPI. Expansion-coefficients that exceed the 'q'-quantile will be used for estimation. Choose such that 0 < q < 1. |
In case of Y =NULL: A list containing:
basis: The Eigenvectors of TPDM
pc: The principal components of TPDM
extremal.basis: The Eigenvectors of TPDM but transformed in positive reals with trans
EPI: Extremal pattern index
In case of Y !=NULL: A list containing:
U, V: The left- and right singular Vectors of cross-TPDM
extr.U, extr.V: The left- and right singular vectors of cross-TPDM, but transformed in positive reals with trans
pcU, pcV: The left- and right expansion coefficients of cross-TPDM
EPI: Extremal pattern index
TEPI: Threshold-based extremal pattern index
Szemkus & Friederichs 2023
data <- precipGER result <- wrapper.EPI(data$pr, m = 1:50) rbPal <- colorRampPalette(c('blue', 'white','red')) Col <- rbPal(10)[as.numeric(cut(result$basis[,2],breaks = 10))] plot(data$lat, data$lon,col=Col) plot(data$date, result$EPI, type='l')
data <- precipGER result <- wrapper.EPI(data$pr, m = 1:50) rbPal <- colorRampPalette(c('blue', 'white','red')) Col <- rbPal(10)[as.numeric(cut(result$basis[,2],breaks = 10))] plot(data$lat, data$lon,col=Col) plot(data$date, result$EPI, type='l')