Factor Family Basis Transforms: private API
Types
PortfolioOptimisers.ChangedDesign — Type
struct ChangedDesign{__T_B, __T_P}The exposures of a design and the changes that go with them, after the rules that change the design.
This type is an implementation detail and is not intended for direct use. cs_dropped_design and cs_regression_design make it for the exposure history of a regression. attribution_dropped_observation makes it for one observation. cs_regression_t_stats reads it.
Fields
B:B: The exposures of the design. An exposure historyassets × factors × observations, or the exposures of one observationassets × factors.
P:P: The changes of the design. Thet => P_tpairs ofunseen_member_design, or the changeP_tof one observation, ornothingor()when there is none.
Related
Functions
PortfolioOptimisers.assert_factor_basis_index — Function
assert_factor_basis_index(
t::Integer,
fcb::FactorFamilyBasis
)
Refuse an observation index that does not lie on the observation axis of the basis.
Arguments
t::Integer: Observation index.fcb: A Factor Family Basis.
Validation
1 <= t <= size(fcb.ratios, 1).
Returns
nothing.
Related
PortfolioOptimisers.unseen_member_change — Function
unseen_member_change(
fcb::FactorFamilyBasis,
Bt::AbstractMatrix{<:Union{Number, AbstractJuMPScalar}},
at::AbstractVector{Bool},
t::Integer
) -> Union{Nothing, Matrix}
Return the change of the reduced design of one observation under ZeroUnseenMember, or nothing when the observation needs none.
A family needs a change when the sample does not see its dropped member, or when it does not see a retained member that carries a ratio other than zero. unseen_member_design states the change and its mathematics.
Arguments
fcb: The Factor Family Basis of the lagged exposures.Bt: The lagged exposures of the observation on the raw axis,assets × factors.at:trueat each asset of positive weight at the observation.t: The observation, a row offcb.ratios.
Returns
Pt::Option{<:Matrix}: The change,reduced factors × reduced factors, ornothing.
Related
PortfolioOptimisers.unseen_member_family! — Function
unseen_member_family!(
Pt::Matrix,
red::AbstractVector{<:Integer},
r::AbstractVector{<:Union{Number, AbstractJuMPScalar}},
us::AbstractVector{Bool},
ds::Bool
) -> Matrix
Write the change of one constrained Factor Family into the change of the reduced design of one observation.
The column of each retained member that the sample does not see becomes zero. When the sample does not see the dropped member either, the zero-sum condition moves onto the retained member q that the sample sees with the largest $|r_{t}(q)|$: its column becomes zero, and its row holds $-r_{t}(j) / r_{t}(q)$ at each other retained member $j$ that the sample sees. A family whose members the sample sees carry no ratio other than zero keeps the other columns, because the condition then reads the dropped member alone.
Arguments
Pt: The change of the observation, modified in place.red: The reduced-axis index of each retained member of the family.r: The ratio of each retained member at the observation.us:trueat each retained member that the sample does not see.ds: Whether the sample sees the dropped member.
Returns
Pt::Matrix: The change, modified in place.
Related
PortfolioOptimisers.unseen_member_returns — Function
unseen_member_returns(
csr::CrossSectionalRegression,
P
) -> CrossSectionalRegression
Map the coefficients of a regression on the design of unseen_member_design back to the reduced factor returns.
The row of each changed observation t becomes P_t times the coefficients of that row. Every other row, the residuals, the counts, the intercept, the leverage-one mark and the dropped-column mask stay as the regression gives them. The mask names the columns of the changed design, so a diagnostic composes it with P_t. The design times the coefficients equals the reduced exposures times the factor returns, so the residuals are those of the factor returns.
Arguments
csr: The regression on the changed design.P: Thet => P_tpairs ofunseen_member_design.
Returns
csr::CrossSectionalRegression: The regression with the reduced factor returns inf. It iscsritself whenPis empty.
Related
PortfolioOptimisers.unseen_member_change_at — Function
unseen_member_change_at(P, t::Integer) -> Any
Return the change of the reduced design of one observation from the pairs of unseen_member_design, or nothing when the observation has none.
A consumer that rebuilds the design of each observation reads the change of that observation here, so an observation without a change takes its usual code.
Arguments
P: Thet => P_tpairs ofunseen_member_design.t: The observation.
Returns
Pt::Option{<:AbstractMatrix}: The change of observationt, ornothing.
Related
PortfolioOptimisers.cs_dropped_design — Function
cs_dropped_design(B::Arr3Num, P, dc::Nothing) -> ChangedDesign
cs_dropped_design(B::Arr3Num, P, dc::AbstractMatrix{Bool}) -> ChangedDesignReturn the design and the changes that a diagnostic of the factor returns reads, after the columns that the fit dropped.
Under DependentColumnDrop the fit of an observation solves the columns that its rank test keeps, and gives every other factor a return of zero by the rule. So its factor returns are $\mathbf{P}_{t} \mathbf{S}_{t}$ times the coefficients of the kept columns, where $\mathbf{S}_{t}$ is the identity with a zero column at each dropped factor, and $\mathbf{P}_{t}$ is the change of an Unseen Member, or the identity. The verb zeroes the dropped columns of the design and composes the two changes. So a dropped factor has a variance of zero, as an Unseen Member has, because the rule states its return, and the kept factors read the inverse Gram matrix of the kept columns, which the fit solved. Without the mask the diagnostic reads the pseudo-inverse of the whole design, which states no value for any factor of the dependent group.
Arguments
B: The design of the regression,assets × factors × observations, fromcs_regression_data.P: Thet => P_tpairs on the rows ofB.dc: The dropped-column maskobservations × factorson the rows ofB, ornothing.
Returns
dd::ChangedDesign: The design with a zero column at each dropped factor, and the composed changes.BandPthemselves when the mask drops nothing.
Related
PortfolioOptimisers.cs_dropped_change — Function
cs_dropped_change(Pt::Option{<:AbstractMatrix}, d::AbstractVector{Bool},
cols::AbstractVector{<:Integer}, K::Integer, ::Type{T})Return the change of one observation, composed with the selection of the columns that its fit kept.
The selection $\mathbf{S}_{t}$ is the identity of order K with a zero column at cols[d], and the answer is $\mathbf{P}_{t} \mathbf{S}_{t}$, or $\mathbf{S}_{t}$ when the observation has no change. cs_dropped_design states the rule.
Arguments
Pt: The change of the observation,K × K, ornothing.d: The dropped-column mask of the observation, one entry per entry ofcols.cols: The position on the axis of the change of each column of the mask.K: The order of the change.T: Element type of the selection.
Returns
Q::Matrix: The composed change,K × K.
Related