Coverage Universe

An asset is in the coverage universe of one fit when its return is finite and the active mask of the AssetPanel is true at every row of the window. A prior keeps only those assets of its returns matrix and fits each estimator on the smaller matrix. It then puts every result back on the full set of assets, with NaN for each asset outside the coverage universe.

Each of the seven moment functions takes the asset panel as its third positional argument. The default method of each function removes the assets outside the coverage universe and puts them back as NaN. An estimator that reads the masks itself has its own method, and receives the whole window.

The default methods of the seven moment functions

Statistics.cov — Method
cov(
    ce::AbstractCovarianceEstimator,
    X::AbstractMatrix{<:Union{Number, AbstractJuMPScalar}},
    pnl::Union{Nothing, AssetPanel};
    dims,
    active_mask,
    kwargs...
) -> Any

Fit a moment on the Coverage Universe of an Asset Panel, and expand it to the full asset universe.

This is the root method of cov. The six other verbs, cor, var, std, mean, coskewness and cokurtosis, have root methods of the same shape, and their docstrings refer to this one for the rule.

The Asset Panel is the third positional argument of every moment verb, as it is of prior. The root method of each verb is the reduce-and-expand. It reduces X to its Coverage Universe, gives the clean block to the plain estimator, and writes the result into a NaN frame of the full width.

A plain estimator needs no method of its own and no declaration. A mask-aware estimator overrides this method and reads pnl.amsk itself, because its warm-up, its freezes and its resets depend on the mask. It writes its own frame over the whole window.

The rule has the cost that coverage_mask states. One non-finite return, or one inactive row, in the window puts the asset outside the Coverage Universe of that fit, and its entries of the result are NaN.

A matrix call of a prior gives the active mask as the active_mask keyword, with no panel. The method reads that mask as it reads the mask of a panel, so the two calls reach one Coverage Universe.

Algorithm

  1. Reduce X to its Coverage Universe with coverage_keyword_reduction, which reads active_mask in the place of the active mask of pnl when the caller gives one. The per-asset keywords iv and ivpa take the same slice, and a gap in iv narrows the Coverage Universe when the estimator tree reads the surface, see reads_implied_volatility.
  2. Call the plain estimator on the clean block, with the caller's dims and the reduced keywords. Every column of the block is active at every row, so the method does not pass active_mask on.
  3. Expand the result with expand_moment.

Arguments

  • ce: Covariance estimator.
  • me: Expected returns estimator.
  • ske: Coskewness estimator.
  • kte: Cokurtosis estimator.
  • X: Data matrix observations × assets if the dims keyword does not exist or dims = 1, assets × observations when dims = 2.
  • pnl: Optional AssetPanel. The Coverage Universe of the fit comes from its active mask. If it is nothing, the rule reads only the finiteness of the returns.
  • dims: Dimension along which the computation runs.
  • active_mask: The active mask of X, of the shape of X, or nothing. When it is not nothing, it takes the place of the active mask of pnl.
  • kwargs...: Additional keyword arguments passed to the estimator.

Validation

  • dims in (1, 2).
  • At least one asset must be in the Coverage Universe.
  • When an asset is outside the Coverage Universe, the element type of the moment holds NaN. An Integer or a Rational element type raises an ArgumentError.

Returns

  • The moment on the full asset universe, carrying NaN outside the Coverage Universe.

Related

source
Statistics.cor — Method
cor(
    ce::AbstractCovarianceEstimator,
    X::AbstractMatrix{<:Union{Number, AbstractJuMPScalar}},
    pnl::Union{Nothing, AssetPanel};
    dims,
    active_mask,
    kwargs...
) -> Any

The correlation root of the Asset Panel methods of the moment verbs. It is the reduce-and-expand of Statistics.cov(ce::AbstractCovarianceEstimator, X::MatNum, pnl::Option{<:AssetPanel}; dims::Int = 1, kwargs...), which states the rule and its cost.

Related

source
Statistics.var — Method
var(
    ce::AbstractCovarianceEstimator,
    X::AbstractMatrix{<:Union{Number, AbstractJuMPScalar}},
    pnl::Union{Nothing, AssetPanel};
    dims,
    active_mask,
    kwargs...
) -> Any

The variance root of the Asset Panel methods of the moment verbs. It is the reduce-and-expand of Statistics.cov(ce::AbstractCovarianceEstimator, X::MatNum, pnl::Option{<:AssetPanel}; dims::Int = 1, kwargs...), which states the rule and its cost. The result is a marginal, so it expands along its asset axis alone.

Related

source
Statistics.std — Method
std(
    ce::AbstractCovarianceEstimator,
    X::AbstractMatrix{<:Union{Number, AbstractJuMPScalar}},
    pnl::Union{Nothing, AssetPanel};
    dims,
    active_mask,
    kwargs...
) -> Any

The standard deviation root of the Asset Panel methods of the moment verbs. It is the reduce-and-expand of Statistics.cov(ce::AbstractCovarianceEstimator, X::MatNum, pnl::Option{<:AssetPanel}; dims::Int = 1, kwargs...), which states the rule and its cost. The result is a marginal, so it expands along its asset axis alone.

Related

source
Statistics.mean — Method
mean(
    me::AbstractExpectedReturnsEstimator,
    X::AbstractMatrix{<:Union{Number, AbstractJuMPScalar}},
    pnl::Union{Nothing, AssetPanel};
    dims,
    active_mask,
    kwargs...
) -> Any

The expected returns root of the Asset Panel methods of the moment verbs. It is the reduce-and-expand of Statistics.cov(ce::AbstractCovarianceEstimator, X::MatNum, pnl::Option{<:AssetPanel}; dims::Int = 1, kwargs...), which states the rule and its cost. The result is a marginal, so it expands along its asset axis alone.

Related

source
PortfolioOptimisers.coskewness — Method
coskewness(
    ske::CoskewnessEstimator,
    X::AbstractMatrix{<:Union{Number, AbstractJuMPScalar}},
    pnl::Union{Nothing, AssetPanel};
    dims,
    active_mask,
    kwargs...
) -> Any

The coskewness root of the Asset Panel methods of the moment verbs. It is the reduce-and-expand of Statistics.cov(ce::AbstractCovarianceEstimator, X::MatNum, pnl::Option{<:AssetPanel}; dims::Int = 1, kwargs...), which states the rule and its cost. The result is a pair, so the tensor expands at the pair index and the negative spectral skewness matrix expands as a covariance-like matrix.

Related

source
PortfolioOptimisers.cokurtosis — Method
cokurtosis(
    kte::CokurtosisEstimator,
    X::AbstractMatrix{<:Union{Number, AbstractJuMPScalar}},
    pnl::Union{Nothing, AssetPanel};
    dims,
    active_mask,
    kwargs...
) -> Any

The cokurtosis root of the Asset Panel methods of the moment verbs. It is the reduce-and-expand of Statistics.cov(ce::AbstractCovarianceEstimator, X::MatNum, pnl::Option{<:AssetPanel}; dims::Int = 1, kwargs...), which states the rule and its cost. The result is assets² × assets², so it expands at the pair index on both axes.

Related

source

Estimators that fit each asset on its own observations

An estimator that carries a CoveragePolicy reads the masks itself. Its method with a panel passes it the whole window and the active mask of the panel, and does not remove the assets outside the coverage universe.