Compact Radius Rules: private API
PortfolioOptimisers.compact_radius_dof — Function
compact_radius_dof(rr::Regression, T::Number, N::Integer, K::Integer)
compact_radius_dof(rr::CrossSectionalFactorModel, T::Number, N::Integer, K::Integer)Degrees of freedom the fit behind a loadings block left in each idiosyncratic variance.
Algorithm
- On a
Regression, returnT - K - 1. The block comes from a per-asset time-series fit overKfactors and an intercept, so each residual series spendsK + 1of itsTobservations. - On a
CrossSectionalFactorModel, returnT * (N - K) / N. The block comes from a per-period fit across the cross-section, which spendsKof theNassets each period rather thanKof theTobservations once, so the count is the fraction of each period that survives, over allTperiods.
Neither count is read off the block, because no block records one. FactorPrior writes esigma as the column variances of the reconstruction error under whatever variance estimator it was given, and a Cross-Sectional Factor Prior writes the idiosyncratic covariance its own fit measured. So both counts are the count the fit spent, stated here, and a caller whose estimator spent a different number states it on the rule instead.
Arguments
rr: Fitted loadings block.T: Sample size, the effective one when the prior carries observation weights.N: Number of assets.K: Number of factors the fit spent.
Returns
dof::Number: Degrees of freedom, before the rule refuses a non-positive count.
Related
PortfolioOptimisers.compact_radius_sample_size — Function
compact_radius_sample_size(pr::AbstractPriorResult) -> Any
Effective sample size behind a prior result, Kish's when the result carries observation weights.
A weighted estimate carries the information of sum(w)^2 / sum(w .^ 2) equally weighted observations rather than of size(pr.X, 1) rows, and a rule that prices estimation error reads the former. This is the reading ConcentrationRadius already takes for the same reason, and it is effective_sample_size on the result's own weights, so a Scenario Cap's stated count is read here too.
Arguments
pr: Prior result.
Returns
T::Number: Kish's effective sample size whenpr.wis set, the countpr.ensstates otherwise, and the raw row count when neither is set.
Related
PortfolioOptimisers.compact_reference_weights — Function
compact_reference_weights(::Nothing, N::Integer, ::Any, ::Type{E}) where {E}
compact_reference_weights(w0::VecNum, N::Integer, ::Any, ::Type)
compact_reference_weights(w0::NonFiniteAllocationOptimisationEstimator, N::Integer,
rd::ReturnsResult, ::Type)Reference portfolio a VarianceFraction sizes its penalty at.
Algorithm
- On
nothing, return the equal-weight portfolio over theNassets the span covers. - On a vector, return it, after checking it carries one entry per asset.
- On an optimiser, run
optimiseoverrdand return the weights it produced. The optimiser carries its own solver, so nothing is threaded into the uncertainty-set fit. A set fitted with no returns data beside it refuses, because an optimiser has nothing to run on.
Arguments
w0: Thew0field of the rule.N: Number of assets the span covers.rd: Returns data the set was fitted beside, ornothing.E: Element type of the geometry, which the equal-weight vector is built in.
Validation
- A stated vector carries
Nentries, else aDimensionMismatch. - An optimiser meets a
ReturnsResult, else anIsNothingError. - The optimiser's weights carry
Nentries, else aDimensionMismatch.
Returns
w0::VecNum: Reference portfolio of lengthN.
Related