# Analytics

In this section we document additional analytic modelling functions.

## Reference Rate Covariance Calculations

`DiffFusion.reference_rate_scaling`

— Function```
reference_rate_scaling(
context_key::String,
term::ModelTime,
mdl::Model,
ctx::Context
)
```

Return the scaling vector of a reference rate.

A reference rate is specified as a stochastic process random variable `Y = A' X + b`

. Here, `X`

reprsents the model state variable, `A`

is the resulting scaling vector and `b`

is a deterministic function (not relevant for this purpose).

Reference rates are continuous compounded zero rates and FX rates (or asset prices). Reference rates are identified by a `context_key`

. In addition, zero rates are specified by a positive `term`

. For FX rates we require `term`

equal to zero.

Reference rates for other asset classes are to be added.

The model context `ctx`

is used to identify corresponding model parameters and state variables of the `model`

.

```
reference_rate_scaling(
keys_and_terms::AbstractVector,
mdl::Model,
ctx::Context
)
```

Return the scaling matrix of a reference rates. The scaling matrix represents a list of scaling vectors represented as matrix.

`keys_and_terms`

is a list of tuples. For each tuple, the first element represents the `context_key`

of the reference rate. The second element represents the `term`

of the reference rate.

`DiffFusion.reference_rate_covariance`

— Function```
reference_rate_covariance(
Y1::AbstractVecOrMat,
Y2::AbstractVecOrMat,
mdl::Model,
ch::CorrelationHolder,
s::ModelTime,
t::ModelTime,
)
```

Calculate the covariance matrix for two vector or matrices of reference rates.

```
reference_rate_covariance(
Y1::Tuple,
Y2::Tuple,
mdl::Model,
ch::CorrelationHolder,
s::ModelTime,
t::ModelTime,
)
```

Calculate the scalar covariance for two reference rates.

Reference rates are encoded as tuples `Y1`

and `Y2`

. The first element of a tuple is the `context_key`

. The second element of the tuple is the `term`

.

```
reference_rate_covariance(
keys_and_terms::AbstractVector,
ctx::Context,
mdl::Model,
ch::CorrelationHolder,
s::ModelTime,
t::ModelTime,
)
```

Calculate covariance matrix for a list of reference rates.

`keys_and_terms`

is a list of tuples. For each tuple, the first element represents the `context_key`

of the reference rate. The second element represents the `term`

of the reference rate.

`DiffFusion.reference_rate_volatility_and_correlation`

— Function```
reference_rate_volatility_and_correlation(
keys_and_terms::AbstractVector,
ctx::Context,
mdl::Model,
ch::CorrelationHolder,
s::ModelTime,
t::ModelTime,
)
```

Calculate the volatility vector and correlation matrix for a list of reference rates.

`keys_and_terms`

is a list of tuples. For each tuple, the first element represents the `context_key`

of the reference rate. The second element represents the `term`

of the reference rate.