σμ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
  • 日本語
  • 中文
Bayesian Inference skill›Module 3 · Models and practice›Topic 3.1·~1 hrAdvanced

Hierarchical models and shrinkage

Skill positionModule 3 of 3 · Topic 1 of 4
3.1 Hierarchical models and shrinkage
—Lab score— / 100Total XP—Streak—

Letting many estimates help each other

Suppose you have the average return of 505050 stocks. The best-looking ones are partly good and partly lucky. A hierarchical model says all the true means θi\theta_iθi​ come from one common population, θi∼N(μ,τ2)\theta_i\sim N(\mu,\tau^{2})θi​∼N(μ,τ2), and each observed average yiy_iyi​ is the true mean plus noise with standard error sis_isi​. The stock's own data are then combined with the group: the estimate is pulled toward the group mean μ\muμ. This pull is called shrinkage.

Bi=si2si2+τ2,θ^i=Bi μ+(1−Bi) yi,sd(θi)=(1si2+1τ2)−1/2B_i=\frac{s_i^{2}}{s_i^{2}+\tau^{2}},\qquad \hat\theta_i=B_i\,\mu+(1-B_i)\,y_i,\qquad \mathrm{sd}(\theta_i)=\left(\frac{1}{s_i^{2}}+\frac{1}{\tau^{2}}\right)^{-1/2}Bi​=si2​+τ2si2​​,θ^i​=Bi​μ+(1−Bi​)yi​,sd(θi​)=(si2​1​+τ21​)−1/2(1)

The shrinkage factor BiB_iBi​ is the share of weight given to the group. A noisy stock (large sis_isi​) has BiB_iBi​ near 111 and is pulled strongly to the group mean. A precisely measured stock (small sis_isi​) keeps nearly its own value. If you do not know τ2\tau^{2}τ2, estimate it from the spread: the variance of the yiy_iyi​ across stocks equals τ2\tau^{2}τ2 plus the average si2s_i^{2}si2​. So τ2\tau^{2}τ2 is that variance minus the average noise, never below 000. If the spread is no larger than noise alone would produce, τ2=0\tau^{2}=0τ2=0 and all stocks share one estimate.

Two stocks with the same averageLet the group be μ=8%\mu=8\%μ=8% with τ=2%\tau=2\%τ=2%. Stock A has y=14%y=14\%y=14% with s=4%s=4\%s=4%: B=16/(16+4)=0.8B=16/(16+4)=0.8B=16/(16+4)=0.8, so the estimate is 0.8×8+0.2×14=9.2%0.8\times8+0.2\times14=9.2\%0.8×8+0.2×14=9.2% with standard deviation 1/1/16+1/4=1.79%1/\sqrt{1/16+1/4}=1.79\%1/1/16+1/4​=1.79%. Stock B has the same y=14%y=14\%y=14% but a precise s=1%s=1\%s=1%: B=1/(1+4)=0.2B=1/(1+4)=0.2B=1/(1+4)=0.2, so the estimate is 0.2×8+0.8×14=12.8%0.2\times8+0.8\times14=12.8\%0.2×8+0.8×14=12.8%. The noisy stock is pulled almost all the way back, the precise one hardly at all.
  • Hierarchical model: the true means come from one common population, so every stock's data help all the others.
  • Shrinkage Bi=si2/(si2+τ2)B_i=s_i^{2}/(s_i^{2}+\tau^{2})Bi​=si2​/(si2​+τ2): noisy estimates move a lot, precise ones barely.
  • Estimating τ2\tau^{2}τ2: variance across stocks minus the average noise, never below 000.

Lab · what's graded

  • The shrinkage factor15 pts
  • The shrunk mean of A15 pts
  • The shrunk mean of B10 pts
  • The posterior spread of A10 pts
  • Estimating tau squared15 pts
  • Who is shrunk most10 pts
  • Match the vocabulary10 pts
  • Why shrinking helps15 pts
0/ 8 answered
Tasks
1Numeric answer15 ptsNot answered

Stock A has standard error s=4%s=4\%s=4% and the group spread is τ=2%\tau=2\%τ=2%. What is B=s2/(s2+τ2)B=s^{2}/(s^{2}+\tau^{2})B=s2/(s2+τ2)?

b=b =b=accepted: ± 0.005
2Numeric answer15 ptsNot answered

The group mean is μ=8%\mu=8\%μ=8% and stock A averaged y=14%y=14\%y=14%. What is the shrunk mean Bμ+(1−B)yB\mu+(1-B)yBμ+(1−B)y with B=0.8B=0.8B=0.8, in percent? Give two decimals.

m=m =m=accepted: ± 0.03
3Numeric answer10 ptsNot answered

Stock B also averaged y=14%y=14\%y=14% but its standard error is only s=1%s=1\%s=1%, so B=1/(1+4)=0.2B=1/(1+4)=0.2B=1/(1+4)=0.2. What is its shrunk mean, in percent? Give two decimals.

m=m =m=accepted: ± 0.03
4Numeric answer10 ptsNot answered

What is the posterior standard deviation of stock A's true mean, (1/s2+1/τ2)−1/2\big(1/s^{2}+1/\tau^{2}\big)^{-1/2}(1/s2+1/τ2)−1/2 with s=4s=4s=4 and τ=2\tau=2τ=2, in percent? Give two decimals.

s=s =s=accepted: ± 0.02
5Numeric answer15 ptsNot answered

Across the stocks the variance of the observed averages is 303030 (in squared percent) and the average of si2s_i^{2}si2​ is 202020. What is the method-of-moments estimate of τ2\tau^{2}τ2?

t=t =t=accepted: ± 0.01
6Choice10 ptsNot answered

Which stock's average is pulled most strongly toward the group mean?

7Match10 ptsNot answered

Match each symbol with its meaning.

Pick the partner of each item on the left.

μ\muμ
τ\tauτ
sis_isi​
BiB_iBi​
8Explain in words15 ptsNot answered

In one or two sentences, explain why shrinking each stock's average toward the group average usually predicts its future average better than the raw average.

Math modeKeyboard or LaTeX inputTask 1 of 8 · 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