Cross-Sectional Factor Axis
Functions
PortfolioOptimisers.cross_sectional_factor_axis — Function
cross_sectional_factor_axis(
factors::AbstractVector{<:Pair},
rd::ReturnsResult
) -> @NamedTuple{nf::Vector{String}, fam::Vector{String}}
Return the cross-sectional factor axis a set of Factor Exposures produces, before any fit.
The axis is fixed by the Asset Panel's field index, so it is the same in every fold. A caller who writes a FactorSpace mandate reads it before a prior exists, and the fitted CrossSectionalFactorModel stores the same answer in its nf and fam.
Algorithm
- Take the Pairs in the order the caller wrote them, which is the column order of the exposures.
- Expand each Pair through
exposure_axis_names, so a one-hot member contributes one name per level. - Refuse a repeated factor name.
Arguments
factors: Pairs offactor name => Exposure Estimator.rd: Returns data carrying the Asset Panel the one-hot levels are read from.
Validation
factorsis not empty.- No factor name appears twice.
Returns
nf::Vector{String}: The raw factor names, in column order.fam::Vector{String}: The Factor Family label of each name.
Related
cross_sectional_factor_axis(
pe::CrossSectionalFactorPrior,
rd::ReturnsResult
) -> @NamedTuple{nf::Vector{String}, fam::Vector{String}}
Return the cross-sectional factor axis a CrossSectionalFactorPrior will produce, before any fit.
The method forwards pe.factors to the Pairs method of cross_sectional_factor_axis, so a caller who holds the estimator reads the axis off it rather than copying the Pairs. A one-hot member's levels are read off the Asset Panel rd carries, so the answer is fixed by the panel's field index and is the same in every fold.
Arguments
pe: Cross-Sectional Factor Prior estimator.rd: Returns data carrying the Asset Panel the one-hot levels are read from.
Validation
- The rules of the Pairs method of
cross_sectional_factor_axis.
Returns
nf::Vector{String}: The raw factor names, in column order.fam::Vector{String}: The Factor Family label of each name.
Related
PortfolioOptimisers.cross_sectional_factor_sets — Function
cross_sectional_factor_sets(factors::AbstractVector{<:Pair}, rd::ReturnsResult,
sets::Option{<:UniverseSets} = nothing) -> UniverseSetsDeclare the cross-sectional factor axis and its Factor Family groups on a UniverseSets.
Algorithm
- Read the axis with
cross_sectional_factor_axis. - Write the names under
sets.cfkey, sofactor_axis_keyfinds them from aCrossSectionalFactorModel. - Write one plain group per Factor Family label, holding that family's member names. A plain group carries no axis prefix, so a constraint generator reads it as a group of names rather than as a partition of an axis.
- Build the widened
UniverseSets, which re-runs every guard of the constructor.
Arguments
factors: Pairs offactor name => Exposure Estimator.rd: Returns data carrying the Asset Panel the one-hot levels are read from, and the asset names a new sets declares.sets: A declared universe to widen. When it isnothing, a new one is built overrd.nxwith the default key prefixes.
Validation
- The rules of
cross_sectional_factor_axis. - A new sets needs
rd.nx, because the asset axis is the one mandatory axis of aUniverseSets. - A Factor Family label equal to a factor name is refused, unless the family holds that one factor and nothing else. Two different lists would otherwise answer to one name.
- A widened universe that already declares the cross-sectional axis, or a group under a Factor Family label, must declare the same list. A different one is refused rather than replaced, through
cross_sectional_sets_write!. - The rules of
UniverseSets.
Returns
sets::UniverseSets: The declared universe, carrying the cross-sectional factor axis and one group per Factor Family.
Related
cross_sectional_factor_sets(pe::CrossSectionalFactorPrior, rd::ReturnsResult,
sets::Option{<:UniverseSets} = nothing) -> UniverseSetsDeclare the cross-sectional factor axis a CrossSectionalFactorPrior will produce, and its Factor Family groups, on a UniverseSets.
The method forwards pe.factors to the Pairs method of cross_sectional_factor_sets. A caller who writes a FactorSpace mandate against the estimator — in a Pipeline step, or a fold of a cross-validation — declares the universe from the estimator it will fit, so the one-hot level list is never hand-typed.
Arguments
pe: Cross-Sectional Factor Prior estimator.rd: Returns data carrying the Asset Panel the one-hot levels are read from, and the asset names a new sets declares.sets: A declared universe to widen. When it isnothing, a new one is built overrd.nxwith the default key prefixes.
Validation
- The rules of the Pairs method of
cross_sectional_factor_sets.
Returns
sets::UniverseSets: The declared universe, carrying the cross-sectional factor axis and one group per Factor Family.
Related