CalibrationParam-class | R Documentation |
CalibrationParam
provides a simple interface to calculate expected values
and pricing equations for portfolio CDS' and CDO's with different
models.
simulate_dt(object, ...) simulate_adcp(object, times, ...) ## S4 method for signature 'CalibrationParam' simulate_adcp(object, times, ...) probability_distribution(object, times, ...) expected_value(object, times, ...) ## S4 method for signature 'CalibrationParam' expected_value( object, times, ..., method = c("default", "prob", "mc"), n_sim = 10000L, attrs = NULL, .trans_v = NULL, .lagg_ev = NULL, .simulate_pv = NULL ) expected_pcds_equation( object, times, discount_factors, recovery_rate, coupon, upfront, ... ) ## S4 method for signature 'CalibrationParam' expected_pcds_equation( object, times, discount_factors, recovery_rate, coupon, upfront, ... ) expected_cdo_equation( object, times, discount_factors, recovery_rate, lower, upper, coupon, upfront, ... ) ## S4 method for signature 'CalibrationParam' expected_cdo_equation( object, times, discount_factors, recovery_rate, lower, upper, coupon, upfront, ... )
object |
A CalibrationParam-object. |
... |
Pass-through parameters. |
times |
A non-negative numeric vector of timepoints. |
method |
Calculation method (either |
n_sim |
Number of samples. |
attrs |
A named list with functions which are applied to a matrix of present values. |
.trans_v |
Internal parameter, not independent for the user. |
.lagg_ev |
Internal parameter, not independent for the user. |
.simulate_pv |
Internal parameter, not independent for the user. |
discount_factors |
Non-negative numeric vector for the discount factors for the timepoints. |
recovery_rate |
Non-negative number between zero and one for the recovery rate.. |
coupon |
Numeric number for the running coupon. |
upfront |
Numeric number for the upfront payment. |
lower |
Non-negative number between zero and one for the lower attachment point. |
upper |
Non-negative number between zero and one for the upper attachment point. |
simulate_dt()
: simulates the vector of default times and returns a matrix x
with
dim(x) == c(n_sim, getDimension(object))
.
simulate_adcp()
: simulates the average default counting process and returns a
matrix x
with dim(x) == c(n_sim, length(times))
.
simulate_adcp(CalibrationParam)
: simulates the average default counting process and returns a
matrix x
with dim(x) == c(n_sim, length(times))
.
probability_distribution()
: calculates the probability vector for the average default count process
and returns a matrix x
with dim(x) == c(getDimension(object)+1L, length(times))
.
expected_value()
: calculates the expected value for the loss based on the average default
count process for given timepoints and returns a vector x
with
length(x) == length(times)
.
expected_value(CalibrationParam)
: calculates the expected value for the loss based on the average default
count process for given timepoints and returns a vector x
with
length(x) == length(times)
.
expected_pcds_equation()
: calculates the payoff equation for a portfolio CDS (vectorized w.r.t.
the argumentes recovery_rate
, coupon
, and upfront
).
expected_pcds_equation(CalibrationParam)
: calculates the payoff equation for a portfolio CDS (vectorized w.r.t.
the argumentes recovery_rate
, coupon
, and upfront
).
expected_cdo_equation()
: calculates the payoff equation for a CDO (vectorized w.r.t. the
argumentes recovery_rate
, coupon
, and upfront
).
expected_cdo_equation(CalibrationParam)
: calculates the payoff equation for a CDO (vectorized w.r.t. the
argumentes recovery_rate
, coupon
, and upfront
).
dim
The dimension (number of portfolio items).
The probability vector of the average default counting process L
for certain times can be calculated with probability_distribution()
;
i.e. the values
\mathbb{P}(L_t = k/d) , \quad k \in {\{ 0, …, d \}} , \quad t ≥q 0 .
The expectated value of finite linear transformations of the average default counting process
L under a transformation and a linear aggregation can be calculated with
expected_value()
; i.e. the value
\mathbb{E}[diag(A^\top \cdot g(L_t))] , \quad t = (t_1, …, t_m) ≥q 0.
with g : \mathbb{R} \to \mathbb{R}^p A = (a_1, …, a_p) \in R^{m \times p}.
For classes with an implementation of probability_distribution
, method == "prob"
can be
used. In this case the transformation g
(generalized such that g(\mathbb{R}^m) \in
\mathbb{R}^{m \times p}) should be provided via .trans_v(x)
which takes an
\mathbb{R}^m vector and returns a \mathbb{R}^{m\times p} matrix. Furthermore, the
(diagonal of the) linear aggregation should be provided via .lagg_ev(x)
which takes a
\mathbb{R}^{m \times p} matrix and returns an \mathbb{R}^p vector. Both functions
should be vectorized appropriately.
For all classes, method == "prob"
can be used. In this case a function .simulate_pv
should
be provided. This function should draw samples of L_t^{(i)} and return the values of
(a_j^\top \cdot g_j(L_t^{(i)})) in a \mathbb{R}^{n \times p} matrix. A named list
of functions can be provided via attrs
those should take a matrix of simulated pvs as
arguments; their results will be bound to the return values as attributes.
The methods expected_pcds_equation()
and expected_cdo_equation()
are convenience-wrappers for
expected portfolio CDS and CDO payoff-equations.
ExMarkovParam ExMOParam ExtMOParam ArmageddonExtMO2FParam AlphaStableExtMO2FParam PoissonExtMO2FParam ExponentialExtMO2FParam ExtArch2FParam ClaytonExtArch2FParam FrankExtArch2FParam GumbelExtArch2FParam JoeExtArch2FParam
parm <- ExMarkovParam(rmo::exQMatrix(rmo::AlphaStableBernsteinFunction(0.4), d = 5L)) simulate_adcp(parm, 1, n_sim = 10L) simulate_adcp(parm, seq(25e-2, 5, by = 25e-2), n_sim = 10L) expected_value(ArmageddonExtMO2FParam( dim = 50L, lambda = 0.05, rho = 0.4), 0.25, .trans_v = function(x) x, .lagg_ev = function(x) x) expected_value(AlphaStableExtMO2FParam( dim = 50L, lambda = 0.05, rho = 0.4), seq(25e-2, 5, by = 25e-2), .trans_v = function(x) x, .lagg_ev = function(x) apply(x, 2L, mean)) expected_value(PoissonExtMO2FParam( dim = 50L, lambda = 0.05, rho = 0.4), 0.25, .trans_v = function(x) pmin(pmax(0.6 * x - 0.1, 0), 0.2), .lagg_ev = function(x) apply(x, 2L, mean)) expected_value(ExponentialExtMO2FParam( dim = 50L, lambda = 0.05, rho = 0.4), seq(25e-2, 5, by = 25e-2), .trans_v = function(x) pmin(pmax(0.6 * x - 0.1, 0), 0.2), .lagg_ev = function(x) apply(x, 2L, mean)) expected_value(ArmageddonExtMO2FParam( dim = 50L, lambda = 0.05, rho = 0.4), 0.25, method = "mc", n_sim = 1e4L, .simulate_pv = function(object, times, n_sim) simulate_adcp(object, times, n_sim = n_sim)) expected_value(ArmageddonExtMO2FParam( dim = 50L, lambda = 0.05, rho = 0.4), seq(25e-2, 5, by = 25e-2), method = "mc", n_sim = 1e4L, .simulate_pv = function(object, times, n_sim) simulate_adcp(object, times, n_sim = n_sim)) expected_value(ArmageddonExtMO2FParam( dim = 50L, lambda = 0.05, rho = 0.4), seq(25e-2, 5, by = 25e-2), function(x) pmin(pmax(0.6 * x - 0.1, 0), 0.2), method = "mc", n_sim = 1e4L, .simulate_pv = function(object, times, n_sim) simulate_adcp(object, times, n_sim = n_sim), attrs = list(sd = function(x) apply(x, 2L, function(y) sd(y) / sqrt(length(y))))) expected_pcds_equation( AlphaStableExtMO2FParam(dim = 75, lambda = 0.05, rho = 0.6), times = seq(25e-2, 5, by = 25e-2), discount_factors = rep(1, 20L), recovery_rate = 0.4, coupon = 0.08, upfront = 0) expected_pcds_equation( AlphaStableExtMO2FParam(dim = 75, lambda = 0.05, rho = 0.6), times = seq(25e-2, 5, by = 25e-2), discount_factors = rep(1, 20L), recovery_rate = 0.4, coupon = rep(0.08, 4), upfront = rep(0, 4)) expected_pcds_equation( AlphaStableExtMO2FParam(dim = 75, lambda = 0.05, rho = 0.6), times = seq(25e-2, 5, by = 25e-2), discount_factors = rep(1, 20L), recovery_rate = rep(0.4, 4), coupon = rep(0.08, 4), upfront = rep(0, 4)) expected_cdo_equation( ExtGaussian2FParam(dim = 75, lambda = 0.05, rho = 0.6), times = seq(25e-2, 5, by = 25e-2), discount_factors = rep(1, 20L), recovery_rate = 0.4, lower = c(0, 0.1, 0.2, 0.35), upper = c(0.1, 0.2, 0.35, 1), coupon = 0.08, upfront = 0 )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.