Factor risk contribution: private API
PortfolioOptimisers.factor_risk_contribution_td_defaults — Function
factor_risk_contribution_td_defaults(
) -> @NamedTuple{re::StepwiseRegression{PValue{Float64}, ForwardSelection, LinearModel{@NamedTuple{}}, BatchChoice, Nothing, Nothing}, r::Variance{RiskMeasureSettings{Float64, Nothing, Bool}, Nothing, Nothing, Nothing, SquaredSOCRiskExpr, EigenFallbackSquareRoot, SquareRootRatio, Nothing}, obj::MinimumRisk}
Return the static defaults of the FactorRiskContribution fields that can hold a TimeDependent.
The constructor reads them to check each schedule, and time_dependent_field_defaults returns them, so the value of a field outside a fold is written once. A field whose static default is nothing is not in the tuple.
Related
PortfolioOptimisers.set_factor_risk_contribution_constraints! — Method
set_factor_risk_contribution_constraints!(model, re, rd, pr, flag, wi; hedge = false)Create the factor weights of a model, and register the asset weights w as their image in the asset basis.
The # Mathematical definition of FactorRiskContribution states the two forms of the map, which flag selects.
When flag and hedge are both true, the rows $\mathbf{B}_2^\intercal \mathbf{\Sigma} \boldsymbol{w} = \boldsymbol{0}$ fix the off-factor weights at the minimum-variance hedge of the factor exposures $\boldsymbol{w}_1$. They are the first-order condition of $\boldsymbol{w}^\intercal \mathbf{\Sigma} \boldsymbol{w}$ in $\boldsymbol{w}_2$. So the off-factor weights take no risk contribution under the variance, and $\boldsymbol{w}^\intercal \mathbf{\Sigma} \boldsymbol{w} = \boldsymbol{w}_1^\intercal (\mathbf{B}^\intercal \mathbf{\Sigma}^{-1} \mathbf{B})^{-1} \boldsymbol{w}_1$. The weights then lie in a subspace of dimension $N_f$, so a bound that the free off-factor weights meet can make the model infeasible.
resolve_factor_regression picks the loadings, in the order that the value-level factor_risk_contribution uses: a precomputed Regression in re, then the rr of the prior, then a fit on rd. The prior comes before the fit, so the basis of the decision variable is the basis through which the prior projected its moments.
A prior that carries loadings comes before a regression estimator in re. To replace the loadings of a factor prior, pass them as a precomputed Regression in re.
Algorithm
- Pick the loadings
rrwithresolve_factor_regression. - Form
Bt, the transpose of the loadings, andb1, the pseudoinverse ofBt.Nfis the number of columns ofb1. - When
flagistrue, formb2from an orthonormal basis of the null space ofBt, createw1andw2, and registerw. Whenhedgeis alsotrue, add the hedge rows. - When
flagisfalse, setb2 = nothing, createw1, and registerw. - Set the start values of
w1fromwiwithset_initial_w!.
JuMP formulation
Variables
w1: Created, $N_f$ entries.w2: Created whenflag = true, one entry for each column of $\mathbf{B}_2$.
Expressions
w: $\mathbf{B}_1 \boldsymbol{w}_1$, or $\mathbf{B}_1 \boldsymbol{w}_1 + \mathbf{B}_2 \boldsymbol{w}_2$ whenflag = true.
Constraints
cfrb_hedge: $s_c \mathbf{B}_2^\intercal \mathbf{\Sigma} \boldsymbol{w} = \boldsymbol{0}$, whenflag = trueandhedge = true.
Where:
- $\boldsymbol{w}_1$: Factor weights of
FactorRiskContribution, one entry for each of the $N_f$ factors. The asset weights are $\mathbf{B}_1 \boldsymbol{w}_1$, with $\mathbf{B}_1$ the pseudoinverse of $\mathbf{B}^\intercal$, plus an off-factor block whenflag = true. - $\boldsymbol{w}_2$: Off-factor weights, one entry for each direction of the null space of $\mathbf{B}^\intercal$. There are $N - N_f$ of them when $\mathbf{B}$ has full column rank.
- $\boldsymbol{w}$: Portfolio weights vector $N \times 1$.
- $\mathbf{B}_1$: The factor basis, $(\mathbf{B}^\intercal)^{+}$.
- $\mathbf{B}_2$: The off-factor basis, an orthonormal basis of the null space of $\mathbf{B}^\intercal$, $N \times (N - \operatorname{rank}\mathbf{B})$.
- $\mathbf{B}$: Loading matrix, of size $N \times N_{f}$.
- $\mathbf{\Sigma}$: The covariance matrix of the prior,
pr.sigma. - $s_c$: Constraint scale. It multiplies both sides of a row, so a positive value leaves the feasible set unchanged.
Arguments
model: JuMP model.re: Regression result or estimator (RegE_Reg).rd: Returns result that carriesXandF. The method reads it only to fit the loadings.pr: Prior result. The method reads its loadings, andsigmafor the hedge rows.flag:trueadds the off-factor weights.wi: Start values of the factor weights, ornothing.hedge:trueadds the hedge rows. The method reads it only whenflagistrue, and thenprmust carrysigma.
Returns
b1, b2, rr: The factor basis, the off-factor basis, and the loadings of both.b2isnothingwhenflagisfalse.
Related