Cross-Sectional Prior Fold
A CrossSectionalFactorPrior that Online does not wrap updates with each new block of observations. Its first partial_fit! creates a PortfolioOptimisers.CrossSectionalCarryState. Each later update computes the exposures, the regression and the idiosyncratic variance of the new observations alone, from the last panel rows that its descriptors read. Then prior(pe) builds the result with the code of the batch fit.
PortfolioOptimisers.prior — Method
prior(
pe::CrossSectionalFactorPrior,
st::CrossSectionalCarryState;
strict,
cache_reg,
kwargs...
) -> LowOrderPrior
Reads a Cross-Sectional Factor Prior out of its carry fold, with no data.
The call with no data builds the Prior Result with cross_sectional_assemble, the code of the batch fit, from the histories that the state carries and the factor prior that it folded. The idiosyncratic correlation reads the ce that the state folded, or refits there from the carried rows when ce does not fold. The Return Forecast refits there too, unless the state carries its rows, as folds_forecast_rows answers. Then the call reads its Result off those rows with return_forecast_result. The standardised idiosyncratic returns are the rows that the state carries, so the call does not standardise the history again.
Algorithm
- Refuse a state that has not made its first fit.
- Append the observed factors of the fitted observations to the fitted factors with
cross_sectional_carry_append. - Read the factor prior with
cross_sectional_factor_priorover the factor returns of the factors that are not empty and the observed returns, and process and expand its moments withcross_sectional_factor_moments. An Observed Factor is never empty. - Count the residuals of each asset with
variance_counton the foldedve. - Take the returns data of the Return Forecast with
cross_sectional_carry_forecast_returns. - Build the result with
cross_sectional_assemble, with the Return Forecast history and the standardised idiosyncratic returns that the state carries. The block records the position of each fitted row among the kept observations, and no timestamp, because the buffer keeps none. - Record the Shared Series cut of the buffer with
shared_series_record, which writes the marks of the dropped observations and maps each position to its observation among the folded observations.
Arguments
pe: Cross-Sectional Factor Prior estimator.st: The state of its carry fold.strict: Whether to throw an error ifsetsdoes not contain the desired value insets.dict[key]. It is forwarded to the factor prior.cache_reg: Iftrue, a prior stores on its result the cache that its refit under new scenario weights reads: aCrossSectionalFactorPriorthe active mask and the Return Forecast history on its block, and anOpinionPoolingPriorthe rows ofpe1and its pooled weights inpc. The refit of an entropy pooling prior around it then runs no regression and no opinion. Every other prior forwards it to the prior that it wraps. Default isfalse. It is forwarded tocross_sectional_assemble.kwargs...: Additional keyword arguments passed to the matrix processing and the lift.
Validation
stholds a fit:lag + 2observations follow the Descriptor warm-up. AnArgumentErroris thrown otherwise.- The rules of
cross_sectional_assemble.
Returns
pr::LowOrderPrior: The prior that the folded observations state.
Related
PortfolioOptimisers.merge_states — Method
merge_states(
_::CrossSectionalCarryState,
_::CrossSectionalCarryState
)
Refuses to merge two CrossSectionalCarryState fitted on disjoint blocks.
The state is not a sufficient statistic of its own block. The first regression of the second block reads the exposures of the last rows of the first block, the Descriptors of its first rows read the panel rows of the first block, and the idiosyncratic variance and the factor prior fold in the order of the observations. So the two blocks fold in sequence.
Arguments
a: The state of the first block.b: The state of the second block.
Validation
- Always throws an
ArgumentError.
Related
PortfolioOptimisers.port_opt_view — Method
port_opt_view(_::CrossSectionalCarryState, i, args...)
Refuses a view of a CrossSectionalCarryState on a subset of the assets.
The regression of each observation reads every asset of its cross-section, so the factor returns of a sub-universe are not a slice of the factor returns that the state carries.
Arguments
x: The state.i: The selected assets.args...: Not read.
Validation
- Always throws an
ArgumentError.
Related
The carry folds its factor prior one row at a time when PortfolioOptimisers.carry_folds answers true for it. A user prior implements that verb to fold on the carry and to pass FoldOnly.
PortfolioOptimisers.carry_folds — Function
carry_folds(pe)
carry_folds(pe::EmpiricalPrior)Answers whether the carry fold of a CrossSectionalFactorPrior folds the factor prior pe one row at a time, at a cost that does not grow with the stream.
This is the verb of a factor prior that folds, and it is public. A prior that answers true keeps the contract of EmpiricalPrior on its carry route. partial_fit! folds the factor returns of the new observations, observations × factors, into a state that the prior holds, and the first call starts from a prior with no state. A step costs the same however many rows the prior folded before. prior(pe; strict) with no data then reads the LowOrderPrior of every folded row, equal to the batch call over them. The carry fold folds such a prior with cross_sectional_fold_factors, and reads it with cross_sectional_factor_prior. It fits any other prior again over every carried factor return at each call with no data, and carry_growing_parts lists that prior.
The verb is not supports_partial_fit. That verb answers false for an EmpiricalPrior, because the prior keeps its rows, and an outer estimator that holds the rows already refits it from them. The carry fold gives the factor prior its rows and reads its state, so it folds the prior.
An EmpiricalPrior on its carry route answers true when me and ce both answer supports_partial_fit. Its fold refits a member that does not fold over every carried row, as fold_member states. Every other prior answers false, an EmpiricalPrior that holds a SampleBufferState included.
Arguments
pe: The factor prior.
Returns
folds::Bool:truewhen the carry fold folds the factor prior.
Related