σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
σμimplied vol · KKmax(S−K,0)udβρᵢⱼfat tailsPnL · drawdownyield · TdSₜ = μSₜ dt + σSₜ dWₜC = S·N(d₁) − K·e⁻ʳᵀ·N(d₂)σₚ² = wᵀΣwd₁ = [ln(S/K) + (r + σ²⁄2)T] ⁄ σ√T∂V/∂t + ½σ²S²·∂²V/∂S² + rS·∂V/∂S − rV = 0Sharpe = (Rₚ − R_f) ⁄ σₚVaR₉₉ = μ − 2.33σρ = Cov(X,Y) ⁄ σₓσᵧE[Rₚ] = Σ wᵢ·E[Rᵢ]φ(x) = e^(−x²/2) ⁄ √2πE[Rᵢ] = R_f + βᵢ(E[Rₘ] − R_f)dXₜ = θ(μ − Xₜ)dt + σ dWₜσ²ₜ = ω + α·ε²ₜ₋₁ + β·σ²ₜ₋₁C − P = S − K·e⁻ʳᵀΔ = ∂V/∂S Γ = ∂²V/∂S²p = (e^(rΔt) − d) ⁄ (u − d)rₜ = ln(Pₜ ⁄ Pₜ₋₁)E[Xₜ₊₁ | ℱₜ] = Xₜf* = (bp − q) ⁄ bz = (x − μ) ⁄ σP(N=k) = λᵏe^(−λ) ⁄ k!Θ = −∂V/∂Tν = S·φ(d₁)·√Tmin wᵀΣw s.t. wᵀμ = μ*∫Σ∂∞λ
uantCraft AcademyRoadmapsSkills
Ctrl K
AO
+1.2k Learners
LoginJoin ↗
RoadmapsSkills
AO
+1.2k Learners
Login
  • English
  • Français
  • Español
  • العربية
  • Português
  • Deutsch
  • 日本語
  • 中文
Matrix Decompositions skill›Module 5 · Factors and portfolios›Topic 5.1·~55 minAdvanced

Factor models from PCA

Skill positionModule 5 of 5 · Topic 1 of 2
5.1 Factor models from PCA
—Lab score— / 100Total XP—Streak—

A covariance matrix with structure

Clipping and shrinkage clean a full matrix. A factor model builds one with structure instead: returns are driven by a few common factors plus asset-specific noise, r=Bf+ε\mathbf r=B\mathbf f+\boldsymbol\varepsilonr=Bf+ε. Here BBB is the N×kN\times kN×k matrix of loadings, f\mathbf ff holds k≪Nk\ll Nk≪N factor returns with covariance Λ\LambdaΛ, and ε\boldsymbol\varepsilonε are idiosyncratic returns, uncorrelated with each other and with the factors, with variances did_idi​. PCA gives a ready-made version: take the top kkk principal components as the factors.

Σ≈BΛBT+D,D=diag⁡(di),di=Σii−∑jbij2λj,Var⁡(wTr)=(BTw)TΛ(BTw)+∑iwi2di\Sigma\approx B\Lambda B^{T}+D,\qquad D=\operatorname{diag}(d_i),\qquad d_i=\Sigma_{ii}-\sum_{j}b_{ij}^{2}\lambda_j,\qquad \operatorname{Var}(\mathbf w^{T}\mathbf r)=(B^{T}\mathbf w)^{T}\Lambda(B^{T}\mathbf w)+\sum_i w_i^{2}d_iΣ≈BΛBT+D,D=diag(di​),di​=Σii​−j∑​bij2​λj​,Var(wTr)=(BTw)TΛ(BTw)+i∑​wi2​di​(1)

The first term is the systematic part: it depends on the portfolio only through its factor exposures BTwB^{T}\mathbf wBTw. The second is idiosyncratic risk. From PCA, BBB holds the first kkk eigenvectors scaled by λj\sqrt{\lambda_j}λj​​ (or the unscaled eigenvectors with Λ=diag⁡(λj)\Lambda=\operatorname{diag}(\lambda_j)Λ=diag(λj​)), and did_idi​ is whatever variance of asset iii the factors do not explain. The saving is large: instead of N(N+1)/2N(N+1)/2N(N+1)/2 covariances you estimate Nk+NNk+NNk+N numbers. For N=500N=500N=500 and k=5k=5k=5 that is 3,000 instead of 125,250. The model matrix is positive definite whenever all di>0d_i>0di​>0, even if N>TN>TN>T, and it embodies the lesson of clipping: only the top kkk eigen-directions are trusted, the rest becomes diagonal noise.

Two assets and one factorLet one factor have variance λ=4\lambda=4λ=4. Asset 1 has loading b1=0.8b_1=0.8b1​=0.8 and idiosyncratic variance d1=1d_1=1d1​=1; asset 2 has loading b2=0.4b_2=0.4b2​=0.4 and d2=1d_2=1d2​=1. The portfolio w=(0.5,0.5)\mathbf w=(0.5,0.5)w=(0.5,0.5) has exposure 0.5(0.8)+0.5(0.4)=0.60.5(0.8)+0.5(0.4)=0.60.5(0.8)+0.5(0.4)=0.6. Its variance is 0.62⋅4+0.52⋅1+0.52⋅1=1.44+0.5=1.940.6^2\cdot4+0.5^2\cdot1+0.5^2\cdot1=1.44+0.5=1.940.62⋅4+0.52⋅1+0.52⋅1=1.44+0.5=1.94, of which 1.441.441.44 is systematic. For a single asset with total variance 2.52.52.5, loading 0.50.50.5 and a factor of variance 666, the systematic part is 0.52⋅6=1.50.5^2\cdot6=1.50.52⋅6=1.5, the idiosyncratic variance is 2.5−1.5=1.02.5-1.5=1.02.5−1.5=1.0 and the factor explains R2=1.5/2.5=60%R^2=1.5/2.5=60\%R2=1.5/2.5=60% of it. For the twelve stocks of the capstone, the first principal component explains about 40% of the variance of the standardised returns.
  • Structure: Σ≈BΛBT+D\Sigma\approx B\Lambda B^{T}+DΣ≈BΛBT+D, with a few factors and a diagonal idiosyncratic matrix.
  • Savings: Nk+NNk+NNk+N parameters instead of N(N+1)/2N(N+1)/2N(N+1)/2; positive definite if all di>0d_i>0di​>0.
  • Risk split: variance = factor exposure part + idiosyncratic part; diversification removes only the latter.
How many factorsThe number kkk is again a judgement. Too few factors leave common structure in the residuals, so the idiosyncratic matrix is not really diagonal; too many import noise. The Marchenko-Pastur edge from the previous lessons is a sound way to pick kkk, and the final test is whether the factor covariance gives a lower out-of-sample portfolio variance than the sample covariance.

Lab · what's graded

  • Counting parameters10 pts
  • Idiosyncratic variance15 pts
  • Share explained by the factor10 pts
  • Portfolio exposure15 pts
  • Portfolio variance20 pts
  • When the model matrix inverts15 pts
  • What diversification removes15 pts
0/ 7 answered
Tasks
1Numeric answer10 ptsNot answered

A k = 5 factor model for N = 500 stocks estimates the loadings (N k numbers) and the idiosyncratic variances (N numbers). How many numbers is that in total?

numbers=numbers =numbers=accepted: ± 0.5
2Numeric answer15 ptsNot answered

An asset has total variance 2.5 and loads 0.5 on a factor of variance 6. What is its idiosyncratic variance d=Σii−b2λd=\Sigma_{ii}-b^2\lambdad=Σii​−b2λ?

d=d =d=accepted: ± 0.01
3Numeric answer10 ptsNot answered

For the same asset, what percentage of its variance does the factor explain?

R2=R^2 =R2=accepted: ± 0.2
4Numeric answer15 ptsNot answered

The loadings are 0.8 and 0.4 and the weights are 0.5 and 0.5. What is the portfolio's factor exposure bTw\mathbf b^{T}\mathbf wbTw?

exposure=exposure =exposure=accepted: ± 0.005
5Numeric answer20 ptsNot answered

With factor variance 4, exposure 0.6 and idiosyncratic variances 1 and 1 for weights 0.5 and 0.5, compute the portfolio variance 0.62⋅4+∑wi2di0.6^2\cdot4+\sum w_i^2d_i0.62⋅4+∑wi2​di​. Give it to two decimals.

variance=variance =variance=accepted: ± 0.01
6Choice15 ptsNot answered

With more assets than observations (N > T), which statement about the factor-model covariance BΛBT+DB\Lambda B^{T}+DBΛBT+D is true?

7Explain in words15 ptsNot answered

In one or two sentences, say which part of the risk diversification removes and which part it cannot.

Math modeKeyboard or LaTeX inputTask 1 of 7 · Ctrl ⏎ to check

Log in to run your code.

Every lecture is free to read. Create an account or log in to run code, run tests and submit this lab.

  • In-browser IDE with a bash terminal — nothing to install
  • Instant grading, XP and your place on the skill
Create an accountLog in
OR
Continue with GitHub