Title: | Minimum Distance Estimation of Tail Dependence Models |
---|---|
Description: | Provides functions implementing minimal distance estimation methods for parametric tail dependence models, as proposed in Einmahl, J.H.J., Kiriliouk, A., Krajina, A., and Segers, J. (2016) <doi:10.1111/rssb.12114> and Einmahl, J.H.J., Kiriliouk, A., and Segers, J. (2018) <doi:10.1007/s10687-017-0303-7>. |
Authors: | Anna Kiriliouk |
Maintainer: | Anna Kiriliouk <[email protected]> |
License: | GPL-3 |
Version: | 1.0.1 |
Built: | 2024-11-03 04:20:32 UTC |
Source: | https://github.com/cran/tailDepFun |
Computes the asymptotic variance matrix for the Brown-Resnick process, estimated using the pairwise M-estimator or the weighted least squares estimator.
AsymVarBR(locations, indices, par, method, Tol = 1e-05)
AsymVarBR(locations, indices, par, method, Tol = 1e-05)
locations |
A |
indices |
A |
par |
The parameters of the Brown-Resnick process. Either |
method |
Choose between "Mestimator" and "WLS". |
Tol |
For "Mestimator" only. The tolerance in the numerical integration procedure. Defaults to 1e-05. |
The parameters of a The matrix indices
can be either user-defined or returned from the function selectGrid
with cst = c(0,1)
. Calculation might be rather slow for method = "Mestimator"
.
A q
by q
matrix.
Einmahl, J.H.J., Kiriliouk, A., Krajina, A., and Segers, J. (2016). An Mestimator of spatial tail dependence. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 78(1), 275-298.
Einmahl, J.H.J., Kiriliouk, A., and Segers, J. (2018). A continuous updating weighted least squares estimator of tail dependence in high dimensions. Extremes 21(2), 205-233.
locations <- cbind(rep(1:2, 3), rep(1:3, each = 2)) indices <- selectGrid(cst = c(0,1), d = 6, locations = locations, maxDistance = 1) AsymVarBR(locations, indices, par = c(1.5,3), method = "WLS")
locations <- cbind(rep(1:2, 3), rep(1:3, each = 2)) indices <- selectGrid(cst = c(0,1), d = 6, locations = locations, maxDistance = 1) AsymVarBR(locations, indices, par = c(1.5,3), method = "WLS")
Computes the asymptotic variance matrix for the Gumbel model, estimated using the pairwise M-estimator or the weighted least squares estimator.
AsymVarGumbel(indices, par, method)
AsymVarGumbel(indices, par, method)
indices |
A |
par |
The parameter of the Gumbel model. |
method |
Choose between "Mestimator" and "WLS". |
The matrix indices
can be either user defines or returned by selectGrid
. For method = "Mestimator"
, only a grid with exactly two ones per row is accepted, representing the pairs to be used.
A q
by q
matrix.
Einmahl, J.H.J., Kiriliouk, A., Krajina, A., and Segers, J. (2016). An Mestimator of spatial tail dependence. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 78(1), 275-298.
Einmahl, J.H.J., Kiriliouk, A., and Segers, J. (2018). A continuous updating weighted least squares estimator of tail dependence in high dimensions. Extremes 21(2), 205-233.
indices <- selectGrid(c(0,1), d = 3, nonzero = c(2,3)) AsymVarGumbel(indices, par = 0.7, method = "WLS")
indices <- selectGrid(c(0,1), d = 3, nonzero = c(2,3)) AsymVarGumbel(indices, par = 0.7, method = "WLS")
Computes the asymptotic variance matrix for the max-linear model, estimated using the weighted least squares estimator.
AsymVarMaxLinear(indices, par, Bmatrix = NULL)
AsymVarMaxLinear(indices, par, Bmatrix = NULL)
indices |
A |
par |
The parameter vector. |
Bmatrix |
A function that converts the parameter vector theta to a parameter matrix B. If |
A q
by q
matrix.
Einmahl, J.H.J., Kiriliouk, A., and Segers, J. (2018). A continuous updating weighted least squares estimator of tail dependence in high dimensions. Extremes 21(2), 205-233.
indices <- selectGrid(c(0,0.5,1), d = 3, nonzero = 3) AsymVarMaxLinear(indices, par = c(0.1,0.55,0.75))
indices <- selectGrid(c(0,0.5,1), d = 3, nonzero = 3) AsymVarMaxLinear(indices, par = c(0.1,0.55,0.75))
The first three columns represent the weekly negative log-returns of the index prices of the EUROSTOXX50 and of its subindices correspoding to the supersectors chemicals and insurance. The fourth and fifth columns represent the weekly negative log-returns of the index prices of the DAX and the CAC40 indices. The sixth to tenth columnds represent the weekly negative log-returns of the stock prices of Bayer, BASF, Allianz, AXA, and Airliquide respectively.
dataEUROSTOXX
is a matrix with 711 rows and 10 columns.
Yahoo Finance
Einmahl, J.H.J., Kiriliouk, A., and Segers, J. (2018). A continuous updating weighted least squares estimator of tail dependence in high dimensions. Extremes 21(2), 205-233.
data(dataEUROSTOXX) ## Transform data to unit Pareto margins n <- nrow(dataEUROSTOXX) x <- apply(dataEUROSTOXX, 2, function(i) n/(n + 0.5 - rank(i))) ## Define indices in which we evaluate the estimator indices <- selectGrid(c(0,0.5,1), d = 10, nonzero = c(2,3)) start <- c(0.67,0.8,0.77,0.91,0.41,0.47,0.25,0.7,0.72,0.19,0.37,0.7,0.09,0.58) ## Estimate the parameters. Lasts up to ten minutes. EstimationMaxLinear(x, indices, k = 40, method = "WLS", startingValue = start, covMat = FALSE, EURO = TRUE)
data(dataEUROSTOXX) ## Transform data to unit Pareto margins n <- nrow(dataEUROSTOXX) x <- apply(dataEUROSTOXX, 2, function(i) n/(n + 0.5 - rank(i))) ## Define indices in which we evaluate the estimator indices <- selectGrid(c(0,0.5,1), d = 10, nonzero = c(2,3)) start <- c(0.67,0.8,0.77,0.91,0.41,0.47,0.25,0.7,0.72,0.19,0.37,0.7,0.09,0.58) ## Estimate the parameters. Lasts up to ten minutes. EstimationMaxLinear(x, indices, k = 40, method = "WLS", startingValue = start, covMat = FALSE, EURO = TRUE)
Daily maximal speeds of wind gusts, measured in 0.1 m/s. The data are observed at 22 inland weather stations in the Netherlands. Only the summer months are presented here (June, July, August). Also included are the Euclidian coordinates of the 22 weather stations, where a distance of 1 corresponds to 100 kilometers.
dataKNMI$data is a matrix with 672 rows and 22 columns, dataKNMI$loc is a matrix with 22 rows and 2 columns.
KNMI
Einmahl, J.H.J., Kiriliouk, A., Krajina, A., and Segers, J. (2016). An Mestimator of spatial tail dependence. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 78(1), 275-298.
data(dataKNMI) n <- nrow(dataKNMI$data) locations <- dataKNMI$loc x <- apply(dataKNMI$data, 2, function(i) n/(n + 0.5 - rank(i))) indices <- selectGrid(cst = c(0,1), d = 22, locations = locations, maxDistance = 0.5) EstimationBR(x, locations, indices, k = 60, method = "Mestimator", isotropic = TRUE, covMat = FALSE)$theta
data(dataKNMI) n <- nrow(dataKNMI$data) locations <- dataKNMI$loc x <- apply(dataKNMI$data, 2, function(i) n/(n + 0.5 - rank(i))) indices <- selectGrid(cst = c(0,1), d = 22, locations = locations, maxDistance = 0.5) EstimationBR(x, locations, indices, k = 60, method = "Mestimator", isotropic = TRUE, covMat = FALSE)$theta
Estimation the parameters of the Brown-Resnick process, using either the pairwise M-estimator or weighted least squares (WLS).
EstimationBR( x, locations, indices, k, method, isotropic = FALSE, biascorr = FALSE, Tol = 1e-05, k1 = (nrow(x) - 10), tau = 5, startingValue = NULL, Omega = diag(nrow(indices)), iterate = FALSE, covMat = TRUE )
EstimationBR( x, locations, indices, k, method, isotropic = FALSE, biascorr = FALSE, Tol = 1e-05, k1 = (nrow(x) - 10), tau = 5, startingValue = NULL, Omega = diag(nrow(indices)), iterate = FALSE, covMat = TRUE )
x |
An |
locations |
A |
indices |
A |
k |
An integer between 1 and |
method |
Choose between |
isotropic |
A Boolean variable. If |
biascorr |
For |
Tol |
For |
k1 |
For |
tau |
For |
startingValue |
Initial value of the parameters in the minimization routine. Defaults to |
Omega |
A |
iterate |
A Boolean variable. If |
covMat |
A Boolean variable. If |
The parameters of the Brown-Resnick process are either for an isotropic process or
for an anisotropic process. The matrix
indices
can be either user-defined or returned from the function selectGrid
with cst = c(0,1)
. Estimation might be rather slow when iterate = TRUE
or even when covMat = TRUE
.
A list with the following components:
theta |
The estimator using the optimal weight matrix. |
theta_pilot |
The estimator without the optimal weight matrix. |
covMatrix |
The estimated covariance matrix for the estimator. |
value |
The value of the minimized function at theta . |
Einmahl, J.H.J., Kiriliouk, A., and Segers, J. (2018). A continuous updating weighted least squares estimator of tail dependence in high dimensions. Extremes 21(2), 205-233.
Einmahl, J.H.J., Kiriliouk, A., Krajina, A., and Segers, J. (2016). An Mestimator of spatial tail dependence. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 78(1), 275-298.
## define the locations of 9 stations locations <- cbind(rep(c(1:3), each = 3), rep(1:3, 3)) ## select the pairs of locations indices <- selectGrid(cst = c(0,1), d = 9, locations = locations, maxDistance = 1.5) ## The Brown-Resnick process set.seed(1) x <- SpatialExtremes::rmaxstab(n = 1000, coord = locations, cov.mod = "brown", range = 3, smooth = 1) ## Calculate the estimtors. EstimationBR(x, locations, indices, 100, method = "Mestimator", isotropic = TRUE, covMat = FALSE)$theta EstimationBR(x, locations, indices, 100, method = "WLS", isotropic = TRUE, covMat = FALSE)$theta
## define the locations of 9 stations locations <- cbind(rep(c(1:3), each = 3), rep(1:3, 3)) ## select the pairs of locations indices <- selectGrid(cst = c(0,1), d = 9, locations = locations, maxDistance = 1.5) ## The Brown-Resnick process set.seed(1) x <- SpatialExtremes::rmaxstab(n = 1000, coord = locations, cov.mod = "brown", range = 3, smooth = 1) ## Calculate the estimtors. EstimationBR(x, locations, indices, 100, method = "Mestimator", isotropic = TRUE, covMat = FALSE)$theta EstimationBR(x, locations, indices, 100, method = "WLS", isotropic = TRUE, covMat = FALSE)$theta
Estimation the parameter of the Gumbel model, using either the pairwise M-estimator or weighted least squares (WLS).
EstimationGumbel( x, indices, k, method, biascorr = FALSE, k1 = (nrow(x) - 10), tau = 5, covMat = TRUE )
EstimationGumbel( x, indices, k, method, biascorr = FALSE, k1 = (nrow(x) - 10), tau = 5, covMat = TRUE )
x |
An |
indices |
A |
k |
An integer between 1 and |
method |
Choose between |
biascorr |
For |
k1 |
For |
tau |
For |
covMat |
A Boolean variable. If |
The matrix indices
can be either user defined or returned by selectGrid
. For method = "Mestimator"
, only a grid with exactly two ones per row is accepted, representing the pairs to be used.
For WLS
, a list with the following components:
theta |
The estimator with weight matrix identity. |
covMatrix |
The estimated covariance matrix for the estimator. |
value |
The value of the minimized function at theta . |
Einmahl, J.H.J., Kiriliouk, A., and Segers, J. (2018). A continuous updating weighted least squares estimator of tail dependence in high dimensions. Extremes 21(2), 205-233.
Einmahl, J.H.J., Kiriliouk, A., Krajina, A., and Segers, J. (2016). An Mestimator of spatial tail dependence. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 78(1), 275-298.
## Generate data with theta = 0.5 set.seed(1) n <- 1000 cop <- copula::gumbelCopula(param = 2, dim = 3) data <- copula::rCopula(n = n,copula = cop) ## Transform data to unit Pareto margins x <- apply(data, 2, function(i) n/(n + 0.5 - rank(i))) ## Define indices in which we evaluate the estimator indices <- selectGrid(c(0,1), d = 3) EstimationGumbel(x, indices, k = 50, method = "WLS", biascorr = TRUE)
## Generate data with theta = 0.5 set.seed(1) n <- 1000 cop <- copula::gumbelCopula(param = 2, dim = 3) data <- copula::rCopula(n = n,copula = cop) ## Transform data to unit Pareto margins x <- apply(data, 2, function(i) n/(n + 0.5 - rank(i))) ## Define indices in which we evaluate the estimator indices <- selectGrid(c(0,1), d = 3) EstimationGumbel(x, indices, k = 50, method = "WLS", biascorr = TRUE)
Estimation the parameters of the max-linear model, using either the pairwise M-estimator or weighted least squares (WLS).
EstimationMaxLinear( x, indices, k, method, Bmatrix = NULL, Ldot = NULL, biascorr = FALSE, k1 = (nrow(x) - 10), tau = 5, startingValue, Omega = diag(nrow(indices)), iterate = FALSE, covMat = TRUE, GoFtest = FALSE, dist = 0.01, EURO = FALSE )
EstimationMaxLinear( x, indices, k, method, Bmatrix = NULL, Ldot = NULL, biascorr = FALSE, k1 = (nrow(x) - 10), tau = 5, startingValue, Omega = diag(nrow(indices)), iterate = FALSE, covMat = TRUE, GoFtest = FALSE, dist = 0.01, EURO = FALSE )
x |
An |
indices |
A |
k |
An integer between 1 and |
method |
Choose between |
Bmatrix |
A function that converts the parameter vector theta to a parameter matrix B. If nothing is provided, then a simple 2-factor model is assumed. |
Ldot |
For |
biascorr |
For |
k1 |
For |
tau |
For |
startingValue |
Initial value of the parameters in the minimization routine. |
Omega |
A |
iterate |
A Boolean variable. For |
covMat |
A Boolean variable. For |
GoFtest |
A Boolean variable. For |
dist |
A positive scalar. If |
EURO |
A Boolean variable. If |
The matrix indices
can be either user defined or returned by selectGrid
.
For method = "Mestimator"
, only a grid with exactly two ones per row is accepted,
representing the pairs to be used. The functions Bmatrix
and Ldot
can be defined
such that they represent a max-linear model on a directed acyclic graph: see the vignette for this package for an example.
For Mestimator
, the estimator theta
is returned. For WLS
, a list with the following components:
theta |
The estimator with estimated optimal weight matrix. |
theta_pilot |
The estimator without the optimal weight matrix. |
covMatrix |
The estimated covariance matrix for the estimator. |
value |
The value of the minimized function at theta . |
GoFresult |
A list of length two, returning the value of the test statistic and s . |
Einmahl, J.H.J., Kiriliouk, A., and Segers, J. (2018). A continuous updating weighted least squares estimator of tail dependence in high dimensions. Extremes 21(2), 205-233.
## Generate data set.seed(1) n <- 1000 fr <- matrix(-1/log(runif(2*n)), nrow = n, ncol = 2) data <- cbind(pmax(0.3*fr[,1],0.7*fr[,2]),pmax(0.5*fr[,1],0.5*fr[,2]),pmax(0.9*fr[,1],0.1*fr[,2])) ## Transform data to unit Pareto margins x <- apply(data, 2, function(i) n/(n + 0.5 - rank(i))) ## Define indices in which we evaluate the estimator indices <- selectGrid(cst = c(0,0.5,1), d = 3) EstimationMaxLinear(x, indices, k = 100, method = "WLS", startingValue = c(0.3,0.5,0.9)) indices <- selectGrid(cst = c(0,1), d = 3) EstimationMaxLinear(x, indices, k = 100, method = "Mestimator", startingValue = c(0.3,0.5,0.9))
## Generate data set.seed(1) n <- 1000 fr <- matrix(-1/log(runif(2*n)), nrow = n, ncol = 2) data <- cbind(pmax(0.3*fr[,1],0.7*fr[,2]),pmax(0.5*fr[,1],0.5*fr[,2]),pmax(0.9*fr[,1],0.1*fr[,2])) ## Transform data to unit Pareto margins x <- apply(data, 2, function(i) n/(n + 0.5 - rank(i))) ## Define indices in which we evaluate the estimator indices <- selectGrid(cst = c(0,0.5,1), d = 3) EstimationMaxLinear(x, indices, k = 100, method = "WLS", startingValue = c(0.3,0.5,0.9)) indices <- selectGrid(cst = c(0,1), d = 3) EstimationMaxLinear(x, indices, k = 100, method = "Mestimator", startingValue = c(0.3,0.5,0.9))
Returns a regular grid of indices in which to evaluate the stable tail dependence function.
selectGrid(cst, d, nonzero = 2, locations = NULL, maxDistance = 10^6)
selectGrid(cst, d, nonzero = 2, locations = NULL, maxDistance = 10^6)
cst |
A vector containing the values used to construct the grid. Must contain 0. |
d |
An integer, representing the dimension. |
nonzero |
An vector containing integers between |
locations |
A |
maxDistance |
If |
A matrix with q
rows and d
columns, where every row represents a vector in which we will evaluate the stable tail dependence function (for the weighted least squares estimator) or where every row indicates which pairs of variables to use (for the M-estimator)
selectGrid(cst = c(0,0.5,1), d = 3, nonzero = c(2,3)) locations <- cbind(rep(1:3, each = 3), rep(1:3,3)) selectGrid(c(0,1), d = 9, locations = locations, maxDistance = 1.5)
selectGrid(cst = c(0,0.5,1), d = 3, nonzero = c(2,3)) locations <- cbind(rep(1:3, each = 3), rep(1:3,3)) selectGrid(c(0,1), d = 9, locations = locations, maxDistance = 1.5)
Returns the stable tail dependence function in dimension d
, evaluated in a point cst
.
stdfEmp(ranks, k, cst = rep(1, ncol(ranks)))
stdfEmp(ranks, k, cst = rep(1, ncol(ranks)))
ranks |
A |
k |
An integer between 1 and |
cst |
The value in which the tail dependence function is evaluated: defaults to |
A scalar between and
.
Einmahl, J.H.J., Kiriliouk, A., and Segers, J. (2018). A continuous updating weighted least squares estimator of tail dependence in high dimensions. Extremes 21(2), 205-233.
## Simulate data from the Gumbel copula and compute the extremal coefficient in dimension four. set.seed(2) cop <- copula::gumbelCopula(param = 2, dim = 4) data <- copula::rCopula(n = 1000, copula = cop) stdfEmp(apply(data,2,rank), k = 50)
## Simulate data from the Gumbel copula and compute the extremal coefficient in dimension four. set.seed(2) cop <- copula::gumbelCopula(param = 2, dim = 4) data <- copula::rCopula(n = 1000, copula = cop) stdfEmp(apply(data,2,rank), k = 50)
Returns the bias-corrected stable tail dependence function in dimension d
, evaluated in a point cst
.
stdfEmpCorr( ranks, k, cst = rep(1, ncol(ranks)), tau = 5, k1 = (nrow(ranks) - 10) )
stdfEmpCorr( ranks, k, cst = rep(1, ncol(ranks)), tau = 5, k1 = (nrow(ranks) - 10) )
ranks |
A |
k |
An integer between 1 and |
cst |
The value in which the tail dependence function is evaluated: defaults to |
tau |
The parameter of the power kernel. Defaults to 5. |
k1 |
An integer between 1 and |
The values for k1
and tau
are chosen as recommended in Beirlant et al. (2016). This function might be slow for large n
.
A scalar between and
.
Einmahl, J.H.J., Kiriliouk, A., and Segers, J. (2018). A continuous updating weighted least squares estimator of tail dependence in high dimensions. Extremes 21(2), 205-233.
Beirlant, J., Escobar-Bach, M., Goegebeur, Y., and Guillou, A. (2016). Bias-corrected estimation of stable tail dependence function. Journal of Multivariate Analysis, 143, 453-466.
## Simulate data from the Gumbel copula set.seed(2) cop <- copula::gumbelCopula(param = 2, dim = 4) data <- copula::rCopula(n = 1000, copula = cop) stdfEmpCorr(apply(data,2,rank), k = 50)
## Simulate data from the Gumbel copula set.seed(2) cop <- copula::gumbelCopula(param = 2, dim = 4) data <- copula::rCopula(n = 1000, copula = cop) stdfEmpCorr(apply(data,2,rank), k = 50)
Analytical implementation of the integral of the bivariate stable tail dependence function over the unit square.
stdfEmpInt(ranks, k)
stdfEmpInt(ranks, k)
ranks |
A |
k |
An integer between 1 and |
A positive scalar.
Einmahl, J.H.J., Kiriliouk, A., Krajina, A., and Segers, J. (2016). An Mestimator of spatial tail dependence. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 78(1), 275-298.
ranks <- cbind(sample(1:20), sample(1:20)) stdfEmpInt(ranks, k = 5)
ranks <- cbind(sample(1:20), sample(1:20)) stdfEmpInt(ranks, k = 5)
The package tailDepFun
provides functions implementing two rank-based minimal distance estimation
methods for parametric tail dependence models for distributions attracted to a max-stable law.
The estimators, referred to as the pairwise M-estimator and the weighted least squares estimator, are
described in Einmahl et al. (2016a) and Einmahl et al. (2016b). Extensive examples to illustrate the use
of the package can be found in the accompanying vignette.
Currently, this package allows for estimation of the Brown-Resnick process, the Gumbel (or logistic) model
and max-linear models (possibly on a directed acyclic graph). The main functions of this package are
EstimationBR
, EstimationGumbel
and EstimationMaxLinear
,
but several other functions are exported as well: stdfEmpInt
returns the integral of the bivariate empirical stable tail dependence function over the unit square, and
stdfEmp
and stdfEmpCorr
return the (bias-corrected) empirical stable tail dependence
function. The functions AsymVarBR
, AsymVarGumbel
, AsymVarMaxLinear
return the asymptotic covariance matrices of the estimators. An auxiliary function to select a regular
grid of indices in which to evaluate the stable tail dependence function is exported as well,
selectGrid
. Finally, two datasets are available: dataKNMI
(Einmahl et al., 2016)
and dataEUROSTOXX
(Einmahl et al., 2018).
Einmahl, J.H.J., Kiriliouk, A., Krajina, A., and Segers, J. (2016). An Mestimator of spatial tail dependence. Journal of the Royal Statistical Society: Series B (Statistical Methodology), 78(1), 275-298.
Einmahl, J.H.J., Kiriliouk, A., and Segers, J. (2018). A continuous updating weighted least squares estimator of tail dependence in high dimensions. Extremes 21(2), 205-233.
## get a list of all help files of user-visible functions in the package help(package = tailDepFun)
## get a list of all help files of user-visible functions in the package help(package = tailDepFun)