Centrality Estimator
PortfolioOptimisers.CentralityEstimator — Type
struct CentralityEstimator{__T_pl, __T_ct, __T_x_src} <: AbstractCentralityEstimatorBundles a network source with the centrality algorithm that scores its assets.
pl builds the network or the partition, and ct scores each asset on it.
The network has weights where it can have them. centrality_polarity returns the quantity that ct needs, and centrality_graph gives that quantity from pl. The shortest path algorithms need distances, and EigenvectorCentrality needs similarities.
The centrality vector is the input of the average centrality $\mathbf{C}_n^{\prime} \boldsymbol{w}$ of Equation 6 of [117]. That work computes $\mathbf{C}_n$ on the unweighted adjacency matrix of the tree or of the TMFG. The weights are a choice of this library, and they follow the rule of [136].
The estimator has no override of its own. For the centrality over the topology alone, put TopologyOnly in the ov field of ct. In both cases, this estimator only holds pl and ct.
Five cases run on the unweighted graph, and none of them raises an error. A caller names a configured algorithm and never asks for weights. A source and an algorithm that cannot use weights have no request to refuse. TopologyOnly asks for no weights, and every source can give that, so it is not one of the five cases.
- A clustering estimator as
pl. A precomputedClustersorPhylogenyResultpassed directly tocentrality_vectoris the same case. Neither a partition nor a precomputed phylogeny matrix has edge weights, and neither borrows weights. DegreeCentrality.Graphs.jldoes not read the weights.Pagerank.Graphs.jldoes not read the weights.KatzCentrality.Graphs.katz_centralityreadsadjacency_matrix(g, Bool), and raises anInexactErroron a weighted graph.EigenvectorCentralityon a tree branch. The branch carries no similarity for it to read.
The weighted routes do not read the sep field of a NetworkEstimator. They read the structure, and not the separation closure that phylogeny_matrix builds. At the default HopCount(; n = 1) the two agree, because the closure of a graph at one hop is the graph.
BetweennessCentrality and StressCentrality read the weights, but the weights do not change them on a tree. A tree has exactly one path between two vertices, so the set of shortest paths is the same at all weights. This is a property of the tree, and it does not hold on the similarity branch.
Fields
pl: Network estimator or clustering estimator that builds the structure. The boundNwE_ClErefuses a precomputedPhylogenyResultorClusters.
ct: Centrality algorithm.
x_src: The source of the returns that the clustering, phylogeny or centrality estimator reads,nothingor anAbstractReturnsSource.nothingandDataSourceread the asset returnsrd.X, andnothingreads theXof the Prior Result when the call gives no returns data.ExcessSourcereads the returns in excess of the benchmark,rd.X - rd.B, the Excess Frame.PriorSourcereads theXof the Prior Result, in the frame that the prior fitted in. Under a factor prior thatXis a reconstruction of the rank of the factors, and a scenario window cuts its rows. A stated source that the call cannot give,DataSource()orExcessSource()with no returns data, orPriorSource()on returns data with no Prior Result, gives a warning, and the estimator reads the matrix that the call gives. A call on a bare matrix reads that matrix under every source. An estimator inside another graph estimator keepsnothing, and the outer estimator states the source.
Constructors
CentralityEstimator(; pl::NwE_ClE = NetworkEstimator(), ct::AbstractCentralityAlgorithm = DegreeCentrality(), x_src::Option{<:AbstractReturnsSource} = nothing) -> CentralityEstimatorKeywords correspond to the struct's fields.
Validation
x_src in ALL_RETURNS_SOURCES, seeassert_returns_source. The constructor throws anArgumentErrorotherwise.returns_source(pl) === nothing. The network or clustering estimator reads the matrix that this estimator selects, so it states no source of its own, seeassert_inner_reader. The constructor throws anArgumentErrorotherwise.
Examples
julia> CentralityEstimator()CentralityEstimator pl ┼ NetworkEstimator │ ce ┼ PortfolioOptimisersCovariance │ │ ce ┼ Covariance │ │ │ me ┼ SimpleExpectedReturns │ │ │ │ w ┴ nothing │ │ │ ce ┼ GeneralCovariance │ │ │ │ ce ┼ StatsBase.SimpleCovariance: StatsBase.SimpleCovariance(true) │ │ │ │ w ┴ nothing │ │ │ alg ┼ FullMoment() │ │ │ w ┴ nothing │ │ mp ┼ MatrixProcessing │ │ │ pdm ┼ Posdef │ │ │ │ alg ┼ UnionAll: NearestCorrelationMatrix.Newton │ │ │ │ kwargs ┴ @NamedTuple{}: NamedTuple() │ │ │ dn ┼ nothing │ │ │ dt ┼ nothing │ │ │ alg ┼ nothing │ │ │ order ┴ NTuple{4, Symbol}: (:pdm, :dn, :dt, :alg) │ de ┼ Distance │ │ power ┼ nothing │ │ alg ┴ CanonicalDistance() │ alg ┼ KruskalTree │ │ args ┼ Tuple{}: () │ │ kwargs ┴ @NamedTuple{}: NamedTuple() │ sep ┼ HopCount │ │ n ┼ CountOf │ │ │ val ┴ Int64: 1 │ x_src ┴ nothing ct ┼ DegreeCentrality │ kind ┼ Int64: 0 │ kwargs ┴ @NamedTuple{}: NamedTuple() x_src ┴ nothingRelated
References
- [117] D. Cajas. A Graph Theory Approach to Portfolio Optimization. Available at SSRN 4602019 (2023). Section 2.4.1, Equation 6, and Section 4, Equation 8.
- [136] F. Pozzi, T. Di Matteo and T. Aste. Spread of risk across financial markets: better to invest in the peripheries. Scientific Reports 3, 1665 (2013). Section "Methods", "Centrality and Peripherality measures".
PortfolioOptimisers.obs_weights_view — Method
obs_weights_view(cte::AbstractCentralityEstimator, i)Return the centrality estimator with the observation weights of its children cut to the observations i.
A centrality estimator fits the network or the clusters of its pl on the returns of the solve, and a covariance estimator in that structure can hold fixed observation weights. A Shared Series gap drops observations from those returns, so the weights must lose the same observations, see shared_series_estimator. The estimators are not @propagatable, so this method cuts every field through obs_weights_fields.
Arguments
cte: The centrality estimator. Its keyword constructor takes every field name, as the constructors of the library do.i: The observations to keep: a mask of the full sample, or their positions.
Returns
cte: The estimator at the kept observations.
Related
References
- [117]
- D. Cajas. A Graph Theory Approach to Portfolio Optimization. Available at SSRN 4602019 (2023).
- [136]
- F. Pozzi, T. Di Matteo and T. Aste. Spread of risk across financial markets: better to invest in the peripheries. Scientific Reports 3, 1665 (2013).