QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Private Types | List of all members
DefaultLatentModel< copulaPolicy > Class Template Reference

Default event Latent Model. More...

#include <ql/experimental/credit/defaultprobabilitylatentmodel.hpp>

+ Inheritance diagram for DefaultLatentModel< copulaPolicy >:
+ Collaboration diagram for DefaultLatentModel< copulaPolicy >:

Public Member Functions

 DefaultLatentModel (const std::vector< std::vector< Real > > &factorWeights, LatentModelIntegrationType::LatentModelIntegrationType integralType, const initTraits &ini=initTraits())
 
 DefaultLatentModel (const Handle< Quote > &mktCorrel, Size nVariables, LatentModelIntegrationType::LatentModelIntegrationType integralType, const initTraits &ini=initTraits())
 
void resetBasket (const ext::shared_ptr< Basket > &basket) const
 
Probability conditionalDefaultProbability (Probability prob, Size iName, const std::vector< Real > &mktFactors) const
 
Probability conditionalDefaultProbabilityInvP (Real invCumYProb, Size iName, const std::vector< Real > &m) const
 
Probability probOfDefault (Size iName, const Date &d) const
 
Real defaultCorrelation (const Date &d, Size iNamei, Size iNamej) const
 
Probability probAtLeastNEvents (Size n, const Date &date) const
 
- Public Member Functions inherited from LatentModel< copulaPolicy >
void update () override
 
Size size () const
 
Size numFactors () const
 Number of systemic factors. More...
 
Size numTotalFactors () const
 Number of total free random factors; systemic and idiosyncratic. More...
 
 LatentModel (const std::vector< std::vector< Real > > &factorsWeights, const typename copulaType::initTraits &ini=copulaType::initTraits())
 
 LatentModel (const std::vector< Real > &factorsWeight, const typename copulaType::initTraits &ini=copulaType::initTraits())
 
 LatentModel (Real correlSqr, Size nVariables, const typename copulaType::initTraits &ini=copulaType::initTraits())
 
 LatentModel (const Handle< Quote > &singleFactorCorrel, Size nVariables, const typename copulaType::initTraits &ini=copulaType::initTraits())
 
const std::vector< std::vector< Real > > & factorWeights () const
 Provides values of the factors \( a_{i,k} \). More...
 
const std::vector< Real > & idiosyncFctrs () const
 Provides values of the normalized idiosyncratic factors \( Z_i \). More...
 
Real latentVariableCorrel (Size iVar1, Size iVar2) const
 Latent variable correlations: More...
 
Probability cumulativeY (Real val, Size iVariable) const
 
Probability cumulativeZ (Real z) const
 Cumulative distribution of Z, the idiosyncratic/error factors. More...
 
Probability density (const std::vector< Real > &m) const
 Density function of M, the market/systemic factors. More...
 
Real inverseCumulativeDensity (Probability p, Size iFactor) const
 Inverse cumulative distribution of the systemic factor iFactor. More...
 
Real inverseCumulativeY (Probability p, Size iVariable) const
 
Real inverseCumulativeZ (Probability p) const
 
std::vector< RealallFactorCumulInverter (const std::vector< Real > &probs) const
 
Real latentVarValue (const std::vector< Real > &allFactors, Size iVar) const
 
const copulaTypecopula () const
 
Real integratedExpectedValue (const ext::function< Real(const std::vector< Real > &v1)> &f) const
 
std::vector< RealintegratedExpectedValueV (const ext::function< std::vector< Real >(const std::vector< Real > &v1)> &f) const
 
- Public Member Functions inherited from Observer
 Observer ()=default
 
 Observer (const Observer &)
 
Observeroperator= (const Observer &)
 
virtual ~Observer ()
 
std::pair< iterator, boolregisterWith (const ext::shared_ptr< Observable > &)
 
void registerWithObservables (const ext::shared_ptr< Observer > &)
 
Size unregisterWith (const ext::shared_ptr< Observable > &)
 
void unregisterWithAll ()
 
virtual void update ()=0
 
virtual void deepUpdate ()
 
- Public Member Functions inherited from Observable
 Observable ()
 
 Observable (const Observable &)
 
Observableoperator= (const Observable &)
 
 Observable (Observable &&)=delete
 
Observableoperator= (Observable &&)=delete
 
virtual ~Observable ()=default
 
void notifyObservers ()
 

Protected Member Functions

void update () override
 
Probability conditionalDefaultProbability (const Date &date, Size iName, const std::vector< Real > &mktFactors) const
 
Probability condProbProduct (Real invCumYProb1, Real invCumYProb2, Size iName1, Size iName2, const std::vector< Real > &mktFactors) const
 
Real conditionalProbAtLeastNEvents (Size n, const Date &date, const std::vector< Real > &mktFactors) const
 Conditional probability of n default events or more. More...
 
const ext::shared_ptr< LMIntegration > & integration () const override
 access to integration: More...
 
- Protected Member Functions inherited from LatentModel< copulaPolicy >

Protected Attributes

ext::shared_ptr< Basketbasket_
 
ext::shared_ptr< LMIntegrationintegration_
 
- Protected Attributes inherited from LatentModel< copulaPolicy >
std::vector< std::vector< Real > > factorWeights_
 
Handle< QuotecachedMktFactor_
 
std::vector< RealidiosyncFctrs_
 
Size nFactors_
 Number of systemic factors. More...
 
Size nVariables_
 Number of latent model variables, idiosyncratic terms or model dim. More...
 
copulaType copula_
 

Private Types

typedef copulaPolicy::initTraits initTraits
 

Additional Inherited Members

- Public Types inherited from LatentModel< copulaPolicy >
typedef copulaPolicy copulaType
 
- Public Types inherited from Observer
typedef set_type::iterator iterator
 

Detailed Description

template<class copulaPolicy>
class QuantLib::DefaultLatentModel< copulaPolicy >

Default event Latent Model.

This is a model for joint default events based on a generic Latent Model. It models solely the default events in a portfolio, not making any reference to severities, exposures, etc... An implicit correspondence is stablished between the variables modelled and the names in the basket given by the basket and model variable access indices. The class is parametric on the Latent Model copula.

Definition at line 44 of file defaultprobabilitylatentmodel.hpp.

Member Typedef Documentation

◆ initTraits

typedef copulaPolicy::initTraits initTraits
private

Definition at line 60 of file defaultprobabilitylatentmodel.hpp.

Constructor & Destructor Documentation

◆ DefaultLatentModel() [1/2]

DefaultLatentModel ( const std::vector< std::vector< Real > > &  factorWeights,
LatentModelIntegrationType::LatentModelIntegrationType  integralType,
const initTraits ini = initTraits() 
)
Parameters
factorWeightsLatent model independent factors weights for each variable.
integralTypeIntegration type.
iniCopula initialization if any.
Warning:
Baskets with realized defaults not tested/WIP.

Definition at line 70 of file defaultprobabilitylatentmodel.hpp.

◆ DefaultLatentModel() [2/2]

DefaultLatentModel ( const Handle< Quote > &  mktCorrel,
Size  nVariables,
LatentModelIntegrationType::LatentModelIntegrationType  integralType,
const initTraits ini = initTraits() 
)

Definition at line 79 of file defaultprobabilitylatentmodel.hpp.

Member Function Documentation

◆ resetBasket()

void resetBasket ( const ext::shared_ptr< Basket > &  basket) const

Definition at line 97 of file defaultprobabilitylatentmodel.hpp.

+ Here is the caller graph for this function:

◆ conditionalDefaultProbability() [1/2]

Probability conditionalDefaultProbability ( Probability  prob,
Size  iName,
const std::vector< Real > &  mktFactors 
) const

Returns the probability of default of a given name conditional on the realization of a given set of values of the model independent factors. The date at which the probability is given is implicit in the probability since theres not other time dependence in this model.

Parameters
probUnconditional probability of default.
iNamedesired name.
mktFactorsValue of LM independent factors.
Warning:
Most often it is preferred to use the method below avoiding the cumulative inversion.

Definition at line 114 of file defaultprobabilitylatentmodel.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ update()

void update ( )
overrideprotectedvirtual

This method must be implemented in derived classes. An instance of Observer does not call this method directly: instead, it will be called by the observables the instance registered with when they need to notify any changes.

Implements Observer.

Definition at line 131 of file defaultprobabilitylatentmodel.hpp.

+ Here is the call graph for this function:

◆ conditionalDefaultProbabilityInvP()

Probability conditionalDefaultProbabilityInvP ( Real  invCumYProb,
Size  iName,
const std::vector< Real > &  m 
) const

Returns the probability of default of a given name conditional on the realization of a given set of values of the model independent factors. The date at which the probability is given is implicit in the probability since theres not other time dependent in this model. Same intention as above but provides a performance opportunity, if the integration is along the market factors (as usually is) avoids computing the inverse of the probability on each call.

Parameters
invCumYProbInverse cumul of the unconditional probability of default, has to follow the same copula law for results to be coherent
iNamedesired name.
mValue of LM independent factors.

Definition at line 151 of file defaultprobabilitylatentmodel.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ conditionalDefaultProbability() [2/2]

Probability conditionalDefaultProbability ( const Date date,
Size  iName,
const std::vector< Real > &  mktFactors 
) const
protected

Returns the probability of default of a given name conditional on the realization of a given set of values of the model independent factors.

Parameters
dateThe date for the probability of default.
iNamedesired name.
mktFactorsValue of LM independent factors.

Same intention as the above methods. Usage of this one is typically more expensive because most often the date we call this method with repeats itself and with this one the probability can not be cached outside the call.

Definition at line 179 of file defaultprobabilitylatentmodel.hpp.

+ Here is the call graph for this function:

◆ condProbProduct()

Probability condProbProduct ( Real  invCumYProb1,
Real  invCumYProb2,
Size  iName1,
Size  iName2,
const std::vector< Real > &  mktFactors 
) const
protected

Conditional default probability product, intermediate step in the correlation calculation.

Definition at line 191 of file defaultprobabilitylatentmodel.hpp.

+ Here is the call graph for this function:

◆ conditionalProbAtLeastNEvents()

Real conditionalProbAtLeastNEvents ( Size  n,
const Date date,
const std::vector< Real > &  mktFactors 
) const
protected

Conditional probability of n default events or more.

Definition at line 279 of file defaultprobabilitylatentmodel.hpp.

+ Here is the caller graph for this function:

◆ integration()

const ext::shared_ptr< LMIntegration > & integration ( ) const
overrideprotectedvirtual

access to integration:

Reimplemented from LatentModel< copulaPolicy >.

Definition at line 205 of file defaultprobabilitylatentmodel.hpp.

◆ probOfDefault()

Probability probOfDefault ( Size  iName,
const Date d 
) const

Computes the unconditional probability of default of a given name. Trivial method for testing

Definition at line 211 of file defaultprobabilitylatentmodel.hpp.

+ Here is the call graph for this function:

◆ defaultCorrelation()

Real defaultCorrelation ( const Date d,
Size  iNamei,
Size  iNamej 
) const

Pearsons' default probability correlation. Users should consider specialization on the copula type for specific distributions since that might simplify the integrations, most importantly if this is to be used in calibration of observations for factor coefficients as it is expensive to integrate directly.

Definition at line 249 of file defaultprobabilitylatentmodel.hpp.

+ Here is the caller graph for this function:

◆ probAtLeastNEvents()

Probability probAtLeastNEvents ( Size  n,
const Date date 
) const

Returns the probaility of having a given or larger number of defaults in the basket portfolio at a given time.

Definition at line 237 of file defaultprobabilitylatentmodel.hpp.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ basket_

ext::shared_ptr<Basket> basket_
mutableprotected

Definition at line 57 of file defaultprobabilitylatentmodel.hpp.

◆ integration_

ext::shared_ptr<LMIntegration> integration_
protected

Definition at line 58 of file defaultprobabilitylatentmodel.hpp.