Title: | Joint Quantile and Expected Shortfall Regression |
---|---|
Description: | Simultaneous modeling of the quantile and the expected shortfall of a response variable given a set of covariates, see Dimitriadis and Bayer (2019) <doi:10.1214/19-EJS1560>. |
Authors: | Sebastian Bayer [aut, cre], Timo Dimitriadis [aut] |
Maintainer: | Sebastian Bayer <[email protected]> |
License: | GPL-3 |
Version: | 0.6.2 |
Built: | 2024-10-30 06:50:17 UTC |
Source: | CRAN |
Computes the joint (VaR, ES) loss
esr_loss(r, q, e, alpha, g1 = 2L, g2 = 1L, return_mean = TRUE)
esr_loss(r, q, e, alpha, g1 = 2L, g2 = 1L, return_mean = TRUE)
r |
Vector of returns |
q |
Vector of quantiles |
e |
Vector of expected shortfalls |
alpha |
Probability level |
g1 |
1, 2, see G1_fun |
g2 |
1, 2, 3, 4, 5, see G2_curly_fun, G2_fun |
return_mean |
If TRUE returns the average tick loss, else the individual values |
Fissler and Ziegel (2016)
Estimates a joint linear regression model for the pair (VaR, ES):
esreg(...) ## S3 method for class 'formula' esreg( formula, data = parent.frame(), alpha, g1 = 2L, g2 = 1L, early_stopping = 10, ... ) ## Default S3 method: esreg(xq, xe, y, alpha, g1 = 2L, g2 = 1L, early_stopping = 10, ...)
esreg(...) ## S3 method for class 'formula' esreg( formula, data = parent.frame(), alpha, g1 = 2L, g2 = 1L, early_stopping = 10, ... ) ## Default S3 method: esreg(xq, xe, y, alpha, g1 = 2L, g2 = 1L, early_stopping = 10, ...)
... |
Further arguments (does not apply here) |
formula |
Formula: y ~ x1 + x2 ... | x1 + x2 ... where the first part after the response variable specifies the quantile equation and the second the expected shortfall part. If only one set of regressors is provided it is used for both model specifications. |
data |
data.frame that holds the variables |
alpha |
Probability level |
g1 |
1, 2 (see G1_fun, G1_prime_fun), defaults to 1 |
g2 |
1, 2, 3, 4, 5 (see G2_curly_fun, G2_fun, G2_prime_fun). defaults to 2 |
early_stopping |
Stop the iterated local search if there is no improvement in early_stopping steps. |
xq |
Explanatory variables for the quantile regression equation |
xe |
Explanatory variables for the expected shortfall regression equation |
y |
Response vector |
An esreg object
A Joint Quantile and Expected Shortfall Regression Framework
vcov.esreg
for covariance estimation
# Simulate data (DGP-(2) in the linked paper) set.seed(0) x <- rchisq(1000, df=1) y <- -x + (1 + 0.5 * x) * rnorm(1000) # True quantile and expected shortfall regression parameters (for alpha=0.025) alpha=0.025 true_pars <- c(-1.959964, -1.979982, -2.337803, -2.168901) # Estimate the model using the standard settings fit <- esreg(y ~ x, alpha=alpha) # Compare the different variance-covariance estimators cov1 <- vcov(object=fit, sparsity="iid", sigma_est="ind") cov2 <- vcov(object=fit, sparsity="nid", sigma_est="scl_N") cov3 <- vcov(object=fit, sparsity="nid", sigma_est="scl_sp") print("Comparison of the variance-covariance estimators") print(cbind(Truth=true_pars, Estimate=coef(fit), SE_iid_ind=sqrt(diag(cov1)), SE_nid_N=sqrt(diag(cov2)), SE_nid_sp=sqrt(diag(cov3)))) # Compares estimates using different G2 functions fit1 <- esreg(y ~ x, alpha=alpha, g2=1) fit2 <- esreg(y ~ x, alpha=alpha, g2=2) fit3 <- esreg(y ~ x, alpha=alpha, g2=3) fit4 <- esreg(y ~ x, alpha=alpha, g2=4) fit5 <- esreg(y ~ x, alpha=alpha, g2=5) fits <- sapply(list(fit1, fit2, fit3, fit4, fit5), coef) colnames(fits) <- sapply(1:5, function(i) esreg:::.G_function_names(1, i)[2]) print("Comparison of the five G2 functions") print(rbind(Truth=true_pars, t(fits))) # Usage of different covariates x <- rchisq(1000, df=1) noise <- rnorm(1000) y <- -x + (1 + 0.5 * x) * rnorm(1000) fit <- esreg(y ~ x | x + noise, alpha=0.025) print("Using different covariates for VaR and ES") print(summary(fit))
# Simulate data (DGP-(2) in the linked paper) set.seed(0) x <- rchisq(1000, df=1) y <- -x + (1 + 0.5 * x) * rnorm(1000) # True quantile and expected shortfall regression parameters (for alpha=0.025) alpha=0.025 true_pars <- c(-1.959964, -1.979982, -2.337803, -2.168901) # Estimate the model using the standard settings fit <- esreg(y ~ x, alpha=alpha) # Compare the different variance-covariance estimators cov1 <- vcov(object=fit, sparsity="iid", sigma_est="ind") cov2 <- vcov(object=fit, sparsity="nid", sigma_est="scl_N") cov3 <- vcov(object=fit, sparsity="nid", sigma_est="scl_sp") print("Comparison of the variance-covariance estimators") print(cbind(Truth=true_pars, Estimate=coef(fit), SE_iid_ind=sqrt(diag(cov1)), SE_nid_N=sqrt(diag(cov2)), SE_nid_sp=sqrt(diag(cov3)))) # Compares estimates using different G2 functions fit1 <- esreg(y ~ x, alpha=alpha, g2=1) fit2 <- esreg(y ~ x, alpha=alpha, g2=2) fit3 <- esreg(y ~ x, alpha=alpha, g2=3) fit4 <- esreg(y ~ x, alpha=alpha, g2=4) fit5 <- esreg(y ~ x, alpha=alpha, g2=5) fits <- sapply(list(fit1, fit2, fit3, fit4, fit5), coef) colnames(fits) <- sapply(1:5, function(i) esreg:::.G_function_names(1, i)[2]) print("Comparison of the five G2 functions") print(rbind(Truth=true_pars, t(fits))) # Usage of different covariates x <- rchisq(1000, df=1) noise <- rnorm(1000) y <- -x + (1 + 0.5 * x) * rnorm(1000) fit <- esreg(y ~ x | x + noise, alpha=0.025) print("Using different covariates for VaR and ES") print(summary(fit))
This function matches the estfun function of the sandwich package and returns the estimating functions for the fitted model. It can for instance be used for an OPG estimator of the sigma matrix. For esreg, the dimension of the estimating functions is n x (kq + ke).
estfun.esreg(x, ...)
estfun.esreg(x, ...)
x |
An esreg object |
... |
Further arguments (does not apply here) |
Estimate the lambda matrix.
lambda_matrix(object, sparsity, bandwidth_estimator, misspec)
lambda_matrix(object, sparsity, bandwidth_estimator, misspec)
object |
An esreg object |
sparsity |
The estimator to be used for the sparsity in
|
bandwidth_estimator |
The bandwidth estimator to be used for the iid and nid sparsity estimator, see density_quantile_function
|
misspec |
if TRUE, the estimator accounts for potential misspecification in the model |
Estimate the sigma matrix.
sigma_matrix(object, sigma_est, misspec)
sigma_matrix(object, sigma_est, misspec)
object |
An esreg object |
sigma_est |
The estimator to be used for
|
misspec |
if TRUE, the estimator accounts for potential misspecification in the model |
Estimate the variance-covariance matrix of the joint (VaR, ES) estimator
## S3 method for class 'esreg' vcov(object, method = "asymptotic", ...)
## S3 method for class 'esreg' vcov(object, method = "asymptotic", ...)
object |
An esreg object |
method |
|
... |
Estimate the variance-covariance matrix of the joint (VaR, ES) estimator by the sandwich formula:
Several estimators are available for both matrices and the default options are selected to take into account possible misspecifications in the underlying data.
vcovA( object, sigma_est = "scl_sp", sparsity = "nid", misspec = TRUE, bandwidth_estimator = "Hall-Sheather" )
vcovA( object, sigma_est = "scl_sp", sparsity = "nid", misspec = TRUE, bandwidth_estimator = "Hall-Sheather" )
object |
An esreg object |
sigma_est |
The estimator to be used for
|
sparsity |
The estimator to be used for the sparsity in
|
misspec |
if TRUE, the estimator accounts for potential misspecification in the model |
bandwidth_estimator |
The bandwidth estimator to be used for the iid and nid sparsity estimator, see density_quantile_function
|
Estimate the variance-covariance matrix of the joint (VaR, ES) estimator using the bootstrap.
vcovB(object, bootstrap_method = "iid", B = 1000)
vcovB(object, bootstrap_method = "iid", B = 1000)
object |
An esreg object |
bootstrap_method |
The bootstrap sampling scheme to be used
|
B |
The number of bootstrap iterations |