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 exposuresassets × factors × observations, on the design of the regression.
f:f: The lag-aligned factor returnsobservations × factors.
eps:eps: The lag-aligned residualsobservations × assets.
w:w: The lag-aligned regression weightsobservations × assets, ornothingwhen the block carries no weight history.
P:P: Thet => P_tpairs ofunseen_member_designon the rows of the history.
dc:dc: The lag-aligned dropped-column mask of the fitobservations × factors, ornothingwhen the fit states no mask.
Related
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 historyassets × factors × observations, already lagged.w: Regression weight historyobservations × assets, ornothingfor equal weights.
Validation
!isempty(B).size(w) == (size(B, 3), size(B, 1)), whenwis present.
Returns
mask::Matrix{Bool}:observations × assets. Entry(t, i)istruewhen assetienters the fit of observationt.u::Matrix{<:Real}:observations × assets. The weight of an eligible pair, and zero outside the mask.
Related
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 historyassets × factors × observations, already lagged.u: Resolved weight historyobservations × assets, zero outside the mask.
Returns
G::Array{<:Real, 3}: Gram historyfactors × factors × observations.
Related
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 historyfactors × factors × observations.
Returns
D::Matrix{<:Real}:observations × factors. Rowtis the diagonal of the inverse of slicet,Inffor a coefficient that slice does not identify.
Related
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 matrixfactors × factors, written in place.G: Gram historyfactors × factors × observations.t: Observation to copy.
Returns
nothing.
Related
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: Answerobservations × factors, written in place.Dt: Weighted design of the observation,eligible assets × factors, fromcs_design_slice.t: Observation to write.Pt: The change of the observation fromcs_regression_data, ornothingwhen it has none.
Returns
r::Int: The numeric rank of the design.
Related
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: Answerobservations × factors, written in place.Gt: One Gram slicefactors × factors.t: Observation to write.Pt: The change of the observation, ornothingwhen it has none.
Returns
r::Int: The numeric rank of the slice.
Related
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: Answerobservations × 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
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 historyassets × factors × observations, already lagged.u: Resolved weight historyobservations × assets, zero outside the mask.t: Observation to read.T: Element type of the answer.
Returns
Dt::Matrix{T}:eligible assets × factors.
Related
PortfolioOptimisers.cs_regression_data — Function
cs_regression_data(csfm::CrossSectionalFactorModel) -> RegressionHistoryReturn 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
- Refuse a block that carries no exposure history, or no cross-sectional fit.
- 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. - Map the exposures onto the design of the regression with
cs_regression_design: onto the reduced axis whencsfm.fcbis set, changed under the Unseen Member rulecsfm.unseen, and without the observed factors thatcsfm.fxstates. The factor returnscsr.fare already on that axis.
Arguments
csfm: A cross-sectional factor model block.
Validation
csfm.Msis notnothing, else anIsNothingErrornamingMsis raised.csfm.csris notnothing, else anIsNothingErrornamingcsris raised.
Returns
data::RegressionHistory: The lag-aligned exposures, factor returns, residuals and regression weights, on the design of the regression, thet => P_tpairs ofunseen_member_designon the rows of the answer, and the lag-aligned dropped-column mask of the fit.wisnothingwhen the block carries no regression weight history, anddcisnothingwhen the fit states no mask.cs_dropped_designcomposes the mask with the pairs.
Validation
- The design and
csr.fagree on the factor axis. Raises aDimensionMismatchthat names both counts.
Related
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
lag: Thelagfield of aCrossSectionalFactorModel, ornothing.
Returns
lag::Int: The lag as a count.
Related
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 historyobservations × assets, ornothing.rows: Indices of the observations to keep.
Returns
A::Option{<:MatNum}: The trimmed history, ornothingwhen the block carries none.
Related
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) -> ChangedDesignMap 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: Thefcbfield of aCrossSectionalFactorModel, ornothing.rule: Theunseenfield of the block.B: Lag-aligned exposure historyassets × factors × observations, on the raw axis.w: Lag-aligned regression weight historyobservations × assets, ornothingfor equal weights.no: The number of observed factors.
Returns
rd::ChangedDesign: InB, the exposure history of the factors the regression estimated, changed at each observation with an Unseen Member. InP, thet => P_tpairs ofunseen_member_designon the estimated factors, empty or()when the rule changes no observation.
Related
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 historyassets × factors × observations, already lagged.eps: Residual matrixobservations × assets, already lagged.w: Regression weight historyobservations × assets, ornothingfor 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
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 historyobservations × columns.t: Observation to read.
Returns
val::Bool:truewhen every entry of the row is finite.
Related
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 matrixobservations × assets.u: Resolved weight historyobservations × assets, zero outside the mask.mask: Eligibility maskobservations × assets.t: Observation to read.T: Element type of the answer.
Returns
rss::Real: The weighted residual sum of squares of observationt.
Related
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 matrixobservations × factors, written in place.f: Factor return matrixobservations × factors.D: Diagonal of the inverse Gram,observations × factors.s2: Residual variance of observationtt.tt: Observation to write.
Returns
nothing.
Related
PortfolioOptimisers.cs_assert_gram — Function
cs_assert_gram(G::Nothing, B::Arr3Num)
cs_assert_gram(G::Arr3Num, B::Arr3Num)Check that a Gram history a caller supplied matches the design.
Arguments
G: Gram history the caller holds, ornothing.B: Exposure historyassets × factors × observations, already lagged.
Validation
size(G) == (size(B, 2), size(B, 2), size(B, 3)), whenGis present. Raises aDimensionMismatch.
Returns
nothing.
Related
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, ornothing.
Returns
T::Type:Boolwithout a history, and the real element type ofGotherwise.
Related
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: Answerobservations × factors, written in place.G: Gram history the caller holds, ornothing.B: Exposure historyassets × factors × observations, already lagged.u: Resolved weight historyobservations × assets, zero outside the mask.t: Observation to write.Pt: The change of the observation, ornothing.
Returns
r::Int: The numeric rank of the observation.
Related
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
- Reconstruct the asset returns as the systematic part plus the residual.
- Mask a pair whose reconstructed return is not finite, and a pair whose weight is not positive.
- Normalise the weights of every observation to sum to one.
- 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.
- Answer the coefficient of determination as one less the ratio of the two sums, and
NaNwhere the total sum of squares is zero.
Arguments
B: Exposure historyassets × factors × observations, already lagged.f: Factor return matrixobservations × factors, already lagged.eps: Residual matrixobservations × assets, already lagged.w: Regression weight historyobservations × assets, ornothingfor equal weights.
Validation
!isempty(B), and every history agrees withBon 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, whichcs_score_regressorsreads for the rank of each design.
Related
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, ornothingfor the rank of each observation.B: Exposure historyassets × factors × observations, already lagged.Q: Normalised weight historyobservations × assetsof the score, zero outside its mask.
Returns
k::Vector{<:Integer}: One count per observation.
Related
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 historyassets × factors × observations, already lagged.f: Factor return matrixobservations × factors, already lagged.eps: Residual matrixobservations × assets, already lagged.u0: Regression weightsobservations × assets, zero where the weight is not positive.t: Observation to read.
Returns
n::Int: Number of eligible assets at observationt.
Related
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 historyassets × factors × observations, already lagged.f: Factor return matrixobservations × factors, already lagged.t: Observation to read.i: Asset to read.T: Element type of the answer.
Returns
sys::Real: The exposures of assetiat observationt, weighted by the factor returns of that observation.
Related
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 matrixobservations × 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
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 historyobservations × assets, ornothingfor equal weights.T: Number of observations.N: Number of assets.Tf: Element type of the answer.
Validation
size(w) == (T, N), whenwis present.
Returns
u::Matrix{<:Real}:observations × assets. A non-positive weight reads back as zero.
Related