Cross-Sectional Regression Diagnostics (a): private API

Types

PortfolioOptimisers.RegressionHistory — Type
struct RegressionHistory{__T_B, __T_f, __T_eps, __T_w, __T_P, __T_dc}

The lag-aligned history that a cross-sectional diagnostic reads off a factor model block.

This type is an implementation detail and is not intended for direct use. cs_regression_data makes it. The block methods of the regression and exposure diagnostics read it.

Fields

  • B: B: The lag-aligned exposures assets × factors × observations, on the design of the regression.
  • f: f: The lag-aligned factor returns observations × factors.
  • eps: eps: The lag-aligned residuals observations × assets.
  • w: w: The lag-aligned regression weights observations × assets, or nothing when the block carries no weight history.
  • dc: dc: The lag-aligned dropped-column mask of the fit observations × factors, or nothing when the fit states no mask.

Related

source

Functions

PortfolioOptimisers.cs_estimation_mask_weights — Function
cs_estimation_mask_weights(B::Arr3Num, w::Nothing)
cs_estimation_mask_weights(B::Arr3Num, w::MatNum)

Return the eligibility mask of a cross-sectional regression history, and the weights that go with it.

An asset enters the fit of an observation when every one of its exposures is finite, and when the weight it carries is positive. An infinite weight is positive, so it enters, and every answer of its observation is then NaN. The fit of cross_sectional_regression refuses such a weight, so a block never carries one. The verb returns both answers because every diagnostic of this file needs both. The mask counts the assets, and the weights scale the sums. A method for nothing handles an absent weight matrix, so no caller writes an isnothing test.

Arguments

  • B: Exposure history assets × factors × observations, already lagged.
  • w: Regression weight history observations × assets, or nothing for equal weights.

Validation

  • !isempty(B).
  • size(w) == (size(B, 3), size(B, 1)), when w is present.

Returns

  • mask::Matrix{Bool}: observations × assets. Entry (t, i) is true when asset i enters the fit of observation t.
  • u::Matrix{<:Real}: observations × assets. The weight of an eligible pair, and zero outside the mask.

Related

source
PortfolioOptimisers.cs_gram_from_weights — Function
cs_gram_from_weights(B::Arr3Num, u::MatNum)

Return the weighted Gram history from a mask that a caller has already resolved.

cs_gram resolves the mask itself and calls this method. A diagnostic that has already built its own weights, such as one that also excludes a pair whose residual is not finite, calls this method instead. It then resolves the mask once rather than twice.

Arguments

  • B: Exposure history assets × factors × observations, already lagged.
  • u: Resolved weight history observations × assets, zero outside the mask.

Returns

  • G::Array{<:Real, 3}: Gram history factors × factors × observations.

Related

source
PortfolioOptimisers.cs_gram_inverse_diagonal — Function
cs_gram_inverse_diagonal(G::Arr3Num) -> Matrix{<:Real}

Return the diagonal of the inverse of every slice of a Gram history.

The verb inverts each slice through its singular value decomposition. One formulation covers both cases a design presents. A full-rank slice gets its inverse. A collinear slice gets the limit of the inverse of $\mathbf{G}_{t} + \lambda \mathbf{I}$ as $\lambda$ falls to zero. That limit is the diagonal of the pseudo-inverse for a coefficient the design identifies, and Inf for one it does not identify, because the variance of such a coefficient has no bound.

A design identifies coefficient $k$ when the unit vector $\boldsymbol{e}_{k}$ lies in the row space of the slice. The directions whose singular value falls under the tolerance span the null space, so the verb reads the share of $\boldsymbol{e}_{k}$ that they hold. The share is round-off for an identified coefficient and of order one for another. The diagonal of the pseudo-inverse alone is not the answer for an unidentified coefficient: it is the round-off of the other directions, and a ratio of such round-off looks like a real answer.

The diagonal is the only part any diagnostic of this file reads. The variance inflation factor multiplies it by the diagonal of the slice itself, and the standard error of a factor return scales it by the residual variance.

A Gram matrix formed in floating point squares the condition number of the weighted design, so its rank test drops a direction from a design condition number of about $10^{8}$, where cross_sectional_rank keeps every column up to about $10^{14} / K$. So a diagnostic that holds the design reads it through cs_inverse_diagonal! instead, at the rank of the fit. This verb is for a caller that holds only the Gram history.

Mathematical definition

\[\begin{align} (\mathbf{G}_{t}^{-1})_{kk} &= \begin{cases} \displaystyle\sum_{i \,:\, \sigma_{i} > \tau} \frac{u_{ki} \, v_{ki}}{\sigma_{i}} & \text{if } m_{k} \leq \sqrt{\varepsilon}\,,\\ \infty & \text{otherwise}\,,\end{cases}\\ m_{k} &= \sum_{i \,:\, \sigma_{i} \leq \tau} v_{ki}^{2}\,. \end{align}\]

Where:

  • $\sigma_{i}$, $\boldsymbol{u}_{i}$, $\boldsymbol{v}_{i}$: $i$-th singular value and the two singular vectors of the slice.
  • $\tau = K \, \varepsilon \, \max_{i} \sigma_{i}$: Tolerance below which the verb drops a direction. It is the default tolerance of LinearAlgebra.pinv.
  • $m_{k}$: Share of $\boldsymbol{e}_{k}$ that the null space of the slice holds.
  • $\varepsilon$: Machine epsilon of the element type.
  • $K$: Number of factors.

Arguments

  • G: Gram history factors × factors × observations.

Returns

  • D::Matrix{<:Real}: observations × factors. Row t is the diagonal of the inverse of slice t, Inf for a coefficient that slice does not identify.

Related

source
PortfolioOptimisers.cs_gram_slice! — Function
cs_gram_slice!(Gt::AbstractMatrix, G::Arr3Num, t::Integer)

Copy one slice of a Gram history into a working matrix.

The verbs that read a Gram history read a slice: cs_gram_inverse_diagonal, cs_regression_t_stats when its caller supplies G, and exposure_condition_number. Each needs it as a matrix of one concrete element type, and each reuses one buffer across the observations rather than allocating one per slice.

Arguments

  • Gt: Working matrix factors × factors, written in place.
  • G: Gram history factors × factors × observations.
  • t: Observation to copy.

Returns

  • nothing.

Related

source
PortfolioOptimisers.cs_inverse_diagonal! — Function
cs_inverse_diagonal!(D::AbstractMatrix, Dt::MatNum, t::Integer,
                     Pt::Option{<:AbstractMatrix} = nothing)

Write the diagonal of the inverse Gram matrix of one weighted design into the answer, at the rank of the fit.

The Gram matrix of the design $\mathbf{D}_{t} = \mathbf{U} \mathbf{\Sigma} \mathbf{V}^{\intercal}$ is $\mathbf{V} \mathbf{\Sigma}^{2} \mathbf{V}^{\intercal}$, so its inverse is the sum over the singular directions of $\boldsymbol{v}_{i} \boldsymbol{v}_{i}^{\intercal} / \sigma_{i}^{2}$. The verb keeps the first r directions, where r is the rank that cross_sectional_rank reads, the rank test of the fit. So the answer is the inverse of a full-rank design, and the pseudo-inverse of a collinear one on each coefficient the design identifies. A coefficient whose unit vector the dropped directions hold by more than the square root of the machine epsilon is not identified, and its entry is Inf. cs_gram_inverse_diagonal states the rule.

The verb reads the design rather than its Gram matrix, because a Gram matrix formed in floating point squares the condition number. On a design whose condition number lies between about $10^{8}$ and $10^{14} / K$, the fit solves at full rank, and a test on the Gram matrix would drop a direction that the fit kept.

At an observation with an Unseen Member, the design is the changed design, and the factor returns are $\mathbf{P}_{t}$ times its coefficients. The verb then writes the diagonal of $\mathbf{P}_{t} \mathbf{G}_{t}^{+} \mathbf{P}_{t}^{\intercal}$. It changes the singular vectors by $\mathbf{P}_{t}$, and it measures the share of row $k$ of $\mathbf{P}_{t}$ that the dropped directions hold against the squared norm of the row. A zero row, an Unseen Member, has a variance of zero, because the rule states its return. A column that DependentColumnDrop dropped takes the same route, with a zero column in Dt and a zero column in Pt.

The count of the kept directions is the numeric rank of the design. The standard error of a factor return subtracts it from the asset count, so the verb returns it rather than a second decomposition finding it again.

Arguments

  • D: Answer observations × factors, written in place.
  • Dt: Weighted design of the observation, eligible assets × factors, from cs_design_slice.
  • t: Observation to write.
  • Pt: The change of the observation from cs_regression_data, or nothing when it has none.

Returns

  • r::Int: The numeric rank of the design.

Related

source
PortfolioOptimisers.cs_gram_inverse_diagonal! — Function
cs_gram_inverse_diagonal!(D::AbstractMatrix, Gt::AbstractMatrix, t::Integer,
                          Pt::Option{<:AbstractMatrix} = nothing)

Write the diagonal of the inverse of one Gram slice into the answer.

The verb is cs_inverse_diagonal! for a caller that holds the Gram slice alone. It drops a direction whose singular value falls under the tolerance $\tau$ of cs_gram_inverse_diagonal, which is a test at the scale of the square of the condition number of the design.

Arguments

  • D: Answer observations × factors, written in place.
  • Gt: One Gram slice factors × factors.
  • t: Observation to write.
  • Pt: The change of the observation, or nothing when it has none.

Returns

  • r::Int: The numeric rank of the slice.

Related

source
PortfolioOptimisers.cs_write_inverse_diagonal! — Function
cs_write_inverse_diagonal!(D::AbstractMatrix, t::Integer, V::AbstractMatrix,
                           lam::AbstractVector, r::Integer)

Write the diagonal of an inverse, given its eigenvectors and the reciprocals of its eigenvalues, into the answer.

The first r directions are kept, and the others span the null space. A coefficient whose row of V the null space holds by more than the square root of the machine epsilon of its squared norm is not identified, and its entry is Inf. A zero row has a variance of zero.

Arguments

  • D: Answer observations × factors, written in place.
  • t: Observation to write.
  • V: Eigenvectors of the Gram matrix, one column per direction, already changed by the change of the observation.
  • lam: Reciprocal of the eigenvalue of each kept direction.
  • r: Number of kept directions.

Returns

  • r::Int: The number of kept directions.

Related

source
PortfolioOptimisers.cs_design_slice — Function
cs_design_slice(B::Arr3Num, u::MatNum, t::Integer, ::Type{T})

Return the weighted design of one observation, over the pairs of positive weight.

The rows are the eligible assets of the observation, each scaled by the square root of its weight, which is the design the fit solved. The verb leaves out a pair outside the mask rather than giving it a zero row, so the tolerance of cross_sectional_rank reads the count of eligible assets, as the rank test of the fit does.

Arguments

  • B: Exposure history assets × factors × observations, already lagged.
  • u: Resolved weight history observations × assets, zero outside the mask.
  • t: Observation to read.
  • T: Element type of the answer.

Returns

  • Dt::Matrix{T}: eligible assets × factors.

Related

source
PortfolioOptimisers.cs_regression_data — Function
cs_regression_data(csfm::CrossSectionalFactorModel) -> RegressionHistory

Return the lag-aligned regression history a cross-sectional diagnostic reads off a factor model block.

Every block method of this file starts here. The verb trims the exposures at the tail and the return-like histories at the head, so the exposures of observation $t - \ell$ line up with the returns of observation $t$. The answer is the design the regression ran on. csr.f holds the factors the fit estimated, on the reduced axis when the block carries a family re-basis, so the verb maps the exposures onto the reduced axis, and it drops the observed factors, which are the trailing columns of that axis and which the regression did not estimate. Every answer that carries a factor axis is then on the axis of csr.f.

Algorithm

  1. Refuse a block that carries no exposure history, or no cross-sectional fit.
  2. Trim the exposure history at the tail by csfm.lag, and the factor returns, the residuals and the regression weights at the head by the same count.
  3. Map the exposures onto the design of the regression with cs_regression_design: onto the reduced axis when csfm.fcb is set, changed under the Unseen Member rule csfm.unseen, and without the observed factors that csfm.fx states. The factor returns csr.f are already on that axis.

Arguments

  • csfm: A cross-sectional factor model block.

Validation

  • csfm.Ms is not nothing, else an IsNothingError naming Ms is raised.
  • csfm.csr is not nothing, else an IsNothingError naming csr is raised.

Returns

  • data::RegressionHistory: The lag-aligned exposures, factor returns, residuals and regression weights, on the design of the regression, the t => P_t pairs of unseen_member_design on the rows of the answer, and the lag-aligned dropped-column mask of the fit. w is nothing when the block carries no regression weight history, and dc is nothing when the fit states no mask. cs_dropped_design composes the mask with the pairs.

Validation

  • The design and csr.f agree on the factor axis. Raises a DimensionMismatch that names both counts.

Related

source
PortfolioOptimisers.cs_regression_lag — Function
cs_regression_lag(lag::Nothing)
cs_regression_lag(lag::Integer)

Return the exposure lag of a factor model block as a count.

A block whose lag is nothing has no lag, so the verb answers 0 for it and the stated count otherwise. Two methods make the choice, so no caller writes an isnothing test.

Arguments

Returns

  • lag::Int: The lag as a count.

Related

source
PortfolioOptimisers.cs_lagged_rows — Function
cs_lagged_rows(A::Nothing, rows)
cs_lagged_rows(A::MatNum, rows)

Trim a per-asset history at the head, keeping the rows a lag alignment leaves.

Arguments

  • A: A per-asset history observations × assets, or nothing.
  • rows: Indices of the observations to keep.

Returns

  • A::Option{<:MatNum}: The trimmed history, or nothing when the block carries none.

Related

source
PortfolioOptimisers.cs_regression_design — Function
cs_regression_design(fcb::Nothing, rule::AbstractUnseenMemberRule, B::Arr3Num,
                     w::Option{<:MatNum}, no::Integer) -> ChangedDesign
cs_regression_design(fcb::FactorFamilyBasis, rule::AbstractUnseenMemberRule, B::Arr3Num,
                     w::Option{<:MatNum}, no::Integer) -> ChangedDesign

Map a lag-aligned exposure history onto the design the cross-sectional regression ran on.

A block that carries a family re-basis has a rank-deficient design on the raw axis, because every constrained family sums to zero, so the regression ran on the reduced axis, and the diagnostics answer there too. The basis has the rows of the exposure history, and cs_regression_data trimmed the exposures at the tail, so the verb slices the basis to the rows of B before the basis maps the exposures. A block that carries no re-basis is already on its own axis. The observed factors are the last no columns of either axis, and the regression did not estimate them, so the verb drops them.

At an observation with an Unseen Member, the fit regressed on the reduced exposures times a change $\mathbf{P}_{t}$, so the verb changes the design with unseen_member_design under the rule of the block. The sample of each observation is its pairs of positive regression weight, as in the fit. The observed factors are not in a family, so the verb keeps the block of $\mathbf{P}_{t}$ on the estimated factors.

Arguments

  • fcb: The fcb field of a CrossSectionalFactorModel, or nothing.
  • rule: The unseen field of the block.
  • B: Lag-aligned exposure history assets × factors × observations, on the raw axis.
  • w: Lag-aligned regression weight history observations × assets, or nothing for equal weights.
  • no: The number of observed factors.

Returns

  • rd::ChangedDesign: In B, the exposure history of the factors the regression estimated, changed at each observation with an Unseen Member. In P, the t => P_t pairs of unseen_member_design on the estimated factors, empty or () when the rule changes no observation.

Related

source
PortfolioOptimisers.cs_diagnostic_mask_weights — Function
cs_diagnostic_mask_weights(B::Arr3Num, eps::MatNum, w::Option{<:MatNum})

Return the eligibility mask of a cross-sectional regression diagnostic, and the weights that go with it.

A diagnostic of the fit reads the residual of every pair it counts, so a pair whose residual is not finite leaves the mask on top of the rule cs_estimation_mask_weights states. Every block method of this file resolves this mask before it calls the method that reads the arrays. So an answer from a block reproduces the fit rather than the exposure history alone.

Arguments

  • B: Exposure history assets × factors × observations, already lagged.
  • eps: Residual matrix observations × assets, already lagged.
  • w: Regression weight history observations × assets, or nothing for equal weights.

Validation

  • size(eps) == (size(B, 3), size(B, 1)).

Returns

  • mask::Matrix{Bool}: observations × assets.
  • u::Matrix{<:Real}: observations × assets, zero outside the mask.

Related

source
PortfolioOptimisers.cs_row_is_finite — Function
cs_row_is_finite(A::MatNum, t::Integer)

Return whether every entry of one row of a history is finite.

A cross-sectional fit whose factor returns are not all finite has no t-statistic at that observation, and this is the test that says so.

Arguments

  • A: A history observations × columns.
  • t: Observation to read.

Returns

  • val::Bool: true when every entry of the row is finite.

Related

source
PortfolioOptimisers.cs_weighted_rss — Function
cs_weighted_rss(eps::MatNum, u::MatNum, mask::AbstractMatrix{Bool}, t::Integer, ::Type{T})

Return the weighted residual sum of squares of one observation.

The sum reads the resolved weights, not the normalised ones. The standard error of a factor return divides this sum by its degrees of freedom. cs_regression_score_parts normalises instead, because a score compares observations of different sizes.

Arguments

  • eps: Residual matrix observations × assets.
  • u: Resolved weight history observations × assets, zero outside the mask.
  • mask: Eligibility mask observations × assets.
  • t: Observation to read.
  • T: Element type of the answer.

Returns

  • rss::Real: The weighted residual sum of squares of observation t.

Related

source
PortfolioOptimisers.cs_t_stat_row! — Function
cs_t_stat_row!(t::MatNum, f::MatNum, D::MatNum, s2, tt::Integer)

Write the t-statistics of one observation into the answer.

A factor whose standard error is zero, or Inf because the design does not identify it, keeps the absent answer the caller filled the row with, so this writes only the entries that have one.

Arguments

  • t: T-statistic matrix observations × factors, written in place.
  • f: Factor return matrix observations × factors.
  • D: Diagonal of the inverse Gram, observations × factors.
  • s2: Residual variance of observation tt.
  • tt: Observation to write.

Returns

  • nothing.

Related

source
PortfolioOptimisers.cs_gram_eltype — Function
cs_gram_eltype(G::Nothing)
cs_gram_eltype(G::Arr3Num)

Return the element type that a Gram history a caller supplied adds to the arithmetic of a diagnostic.

Bool is the type that adds nothing, because it promotes to every other number type. So a diagnostic without a Gram history takes the type of its design and its weights alone.

Arguments

  • G: Gram history the caller holds, or nothing.

Returns

  • T::Type: Bool without a history, and the real element type of G otherwise.

Related

source
PortfolioOptimisers.cs_slice_inverse_diagonal! — Function
cs_slice_inverse_diagonal!(D::AbstractMatrix, G::Nothing, B::Arr3Num, u::MatNum,
                           t::Integer, Pt::Option{<:AbstractMatrix})
cs_slice_inverse_diagonal!(D::AbstractMatrix, G::Arr3Num, B::Arr3Num, u::MatNum,
                           t::Integer, Pt::Option{<:AbstractMatrix})

Write the diagonal of the inverse Gram matrix of one observation into the answer, from the design or from the Gram history the caller supplied.

Without a Gram history the verb reads the weighted design through cs_inverse_diagonal!, at the rank of the fit. With one, it reads the slice through cs_gram_inverse_diagonal!, whose rank test reads the square of the condition number of the design.

Arguments

  • D: Answer observations × factors, written in place.
  • G: Gram history the caller holds, or nothing.
  • B: Exposure history assets × factors × observations, already lagged.
  • u: Resolved weight history observations × assets, zero outside the mask.
  • t: Observation to write.
  • Pt: The change of the observation, or nothing.

Returns

  • r::Int: The numeric rank of the observation.

Related

source
PortfolioOptimisers.cs_regression_score_parts — Function
cs_regression_score_parts(B::Arr3Num, f::MatNum, eps::MatNum, w::Option{<:MatNum})

Return the pieces every cross-sectional regression score is built from.

The four scores read the same three quantities: the eligible asset count, the weight-normalised residual sum of squares, and the coefficient of determination. This verb computes them once per score, and no Result holds them, because the scores are independent statistics with no identity between them.

The mask of a score is the finiteness of the asset return, which the exposures, the factor returns and the residuals reconstruct. That differs from the mask of a Gram diagnostic, which reads the exposures and the residuals separately.

Algorithm

  1. Reconstruct the asset returns as the systematic part plus the residual.
  2. Mask a pair whose reconstructed return is not finite, and a pair whose weight is not positive.
  3. Normalise the weights of every observation to sum to one.
  4. Take the weighted residual sum of squares, the weighted mean return and the weighted total sum of squares. Clamp the mean to the range of the returns inside the mask, so a constant cross-section has a total sum of squares of exactly zero.
  5. Answer the coefficient of determination as one less the ratio of the two sums, and NaN where the total sum of squares is zero.

Arguments

  • B: Exposure history assets × factors × observations, already lagged.
  • f: Factor return matrix observations × factors, already lagged.
  • eps: Residual matrix observations × assets, already lagged.
  • w: Regression weight history observations × assets, or nothing for equal weights.

Validation

  • !isempty(B), and every history agrees with B on the axes it shares.

Returns

  • n::Vector{Int}: Eligible asset count of every observation.
  • rss::Vector{<:Real}: Weight-normalised residual sum of squares of every observation.
  • r2::Vector{<:Real}: Coefficient of determination of every observation.
  • Q::Matrix{<:Real}: observations × assets. The normalised weights, zero outside the mask, which cs_score_regressors reads for the rank of each design.

Related

source
PortfolioOptimisers.cs_score_regressors — Function
cs_score_regressors(k::Integer, B::Arr3Num, Q::MatNum)
cs_score_regressors(k::Nothing, B::Arr3Num, Q::MatNum)

Return the effective number of regressors of every cross-sectional fit, which a score charges for.

A fit spends one degree of freedom on each direction of its design, which is the rank of the design rather than its column count. The two differ on a collinear observation, such as one where a level of a constrained family has no member. So nothing takes the numeric rank of the weighted design of each observation, on the mask of the score, through cross_sectional_rank, which is the rank test of the fit. A test on the Gram matrix would square the condition number, and count fewer directions than the fit spent on a design whose condition number exceeds about $10^{8}$. An integer is a count the caller states, and every observation takes it.

Arguments

  • k: Number of regressors, or nothing for the rank of each observation.
  • B: Exposure history assets × factors × observations, already lagged.
  • Q: Normalised weight history observations × assets of the score, zero outside its mask.

Returns

  • k::Vector{<:Integer}: One count per observation.

Related

source
PortfolioOptimisers.cs_score_observation! — Function
cs_score_observation!(
    r::AbstractVector,
    q::AbstractVector,
    B::Arr3Num,
    f::MatNum,
    eps::MatNum,
    u0::MatNum,
    t::Integer
)

Reconstruct the asset returns of one observation, and normalise its weights to sum to one.

The mask of a cross-sectional regression score is the finiteness of the reconstructed asset return, which differs from the mask of a Gram diagnostic. This verb applies that mask. An ineligible pair gets a zero return and a zero weight, so every sum the score takes over the cross-section ignores it.

Arguments

  • r: Reconstructed asset returns of the observation, written in place.
  • q: Normalised weights of the observation, written in place.
  • B: Exposure history assets × factors × observations, already lagged.
  • f: Factor return matrix observations × factors, already lagged.
  • eps: Residual matrix observations × assets, already lagged.
  • u0: Regression weights observations × assets, zero where the weight is not positive.
  • t: Observation to read.

Returns

  • n::Int: Number of eligible assets at observation t.

Related

source
PortfolioOptimisers.cs_systematic_return — Function
cs_systematic_return(B::Arr3Num, f::MatNum, t::Integer, i::Integer, ::Type{T})

Return the part of one asset's return the factors of one observation span.

Arguments

  • B: Exposure history assets × factors × observations, already lagged.
  • f: Factor return matrix observations × factors, already lagged.
  • t: Observation to read.
  • i: Asset to read.
  • T: Element type of the answer.

Returns

  • sys::Real: The exposures of asset i at observation t, weighted by the factor returns of that observation.

Related

source
PortfolioOptimisers.cs_weighted_score_sums — Function
cs_weighted_score_sums(r::AbstractVector, q::AbstractVector, eps::MatNum, t::Integer)

Return the weighted residual and total sums of squares of one observation.

The two sums are the numerator and the denominator of the coefficient of determination, and both read the weights cs_score_observation! normalised.

Arguments

  • r: Reconstructed asset returns of the observation, zero outside the mask.
  • q: Normalised weights of the observation, zero outside the mask.
  • eps: Residual matrix observations × assets, already lagged.
  • t: Observation to read.

Returns

  • rss::Real: Weighted residual sum of squares.
  • tss::Real: Weighted total sum of squares about the weighted mean return.

Related

source
PortfolioOptimisers.cs_estimation_weights_only — Function
cs_estimation_weights_only(w::Nothing, T::Integer, N::Integer, ::Type{Tf})
cs_estimation_weights_only(w::MatNum, T::Integer, N::Integer, ::Type{Tf})

Return the regression weights of a score, without reading the exposures.

A cross-sectional regression score masks on the reconstructed asset return rather than on the exposures, so it resolves its weights here rather than through cs_estimation_mask_weights. An absent weight matrix gives every pair a unit weight.

Arguments

  • w: Regression weight history observations × assets, or nothing for equal weights.
  • T: Number of observations.
  • N: Number of assets.
  • Tf: Element type of the answer.

Validation

  • size(w) == (T, N), when w is present.

Returns

  • u::Matrix{<:Real}: observations × assets. A non-positive weight reads back as zero.

Related

source