esreg: Joint Quantile and Expected Shortfall Regression

Description Usage Arguments Value References See Also Examples

View source: R/esreg.R

Description

Estimates a joint linear regression model for the pair (VaR, ES):

Q_α(Y | Xq) = Xq'β_q

ES_α(Y | Xe) = Xe'β_e

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
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, ...)

Arguments

...

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

Value

An esreg object

References

A Joint Quantile and Expected Shortfall Regression Framework

See Also

vcov.esreg for covariance estimation

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# 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))

esreg documentation built on Nov. 16, 2019, 1:07 a.m.