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

  1. Refuse a state that has not made its first fit.
  2. Append the observed factors of the fitted observations to the fitted factors with cross_sectional_carry_append.
  3. Read the factor prior with cross_sectional_factor_prior over the factor returns of the factors that are not empty and the observed returns, and process and expand its moments with cross_sectional_factor_moments. An Observed Factor is never empty.
  4. Count the residuals of each asset with variance_count on the folded ve.
  5. Take the returns data of the Return Forecast with cross_sectional_carry_forecast_returns.
  6. 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.
  7. 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 if sets does not contain the desired value in sets.dict[key]. It is forwarded to the factor prior.
  • cache_reg: If true, a prior stores on its result the cache that its refit under new scenario weights reads: a CrossSectionalFactorPrior the active mask and the Return Forecast history on its block, and an OpinionPoolingPrior the rows of pe1 and its pooled weights in pc. 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 is false. It is forwarded to cross_sectional_assemble.
  • kwargs...: Additional keyword arguments passed to the matrix processing and the lift.

Validation

  • st holds a fit: lag + 2 observations follow the Descriptor warm-up. An ArgumentError is thrown otherwise.
  • The rules of cross_sectional_assemble.

Returns

  • pr::LowOrderPrior: The prior that the folded observations state.

Related

source
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

source

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: true when the carry fold folds the factor prior.

Related

source