σμ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
  • 日本語
  • 中文
Particle filtering and non-stationary time series skill›Module 2 · Particle filters›Topic 2.5·~1 hrAdvanced

Learning the parameters

Skill positionModule 2 of 3 · Topic 5 of 5
2.5 Learning the parameters
—Lab score— / 100Total XP—Streak—

Learning the model's own numbers

Until now the numbers of the model, such as qqq, rrr, μ\muμ, φ\varphiφ and σ\sigmaσ, were given. In practice you must learn them from the same data. A particle filter helps in two ways. First, it estimates the likelihood of the data for any choice θ\thetaθ of the numbers: on each day, the average of the particle weights estimates how probable that day's return was, and the sum of the logs of these averages is the log-likelihood. Run the filter for several choices of θ\thetaθ on a grid, always with the same random numbers so the comparison is smooth, and keep the best. The estimate is noisy, with a spread of about 333 on a log-likelihood near 17,75017{,}75017,750, so only gaps larger than that mean something.

log⁡L^(θ)=∑tlog⁡(1N∑iwt(i)),h2=1−(3δ−12δ)2,a=1−h2,θ′=a θ+(1−a) θˉ+hV z\log\hat L(\theta)=\sum_t\log\left(\frac1N\sum_i w_t^{(i)}\right),\qquad h^{2}=1-\left(\frac{3\delta-1}{2\delta}\right)^{2},\quad a=\sqrt{1-h^{2}},\quad \theta'=a\,\theta+(1-a)\,\bar\theta+h\sqrt V\,zlogL^(θ)=t∑​log(N1​i∑​wt(i)​),h2=1−(2δ3δ−1​)2,a=1−h2​,θ′=aθ+(1−a)θˉ+hV​z(1)

The second way puts the unknown number inside the state: every particle carries its own value of θ\thetaθ. This fails if θ\thetaθ is never moved, because resampling then copies a few values and the cloud of θ\thetaθ collapses to one point. The Liu-West fix moves each particle's θ\thetaθ a little after each resampling, but in a way that keeps the cloud's mean and spread. Choose a discount δ\deltaδ near 111 (such as 0.950.950.95). Then h2=1−((3δ−1)/(2δ))2h^{2}=1-\big((3\delta-1)/(2\delta)\big)^{2}h2=1−((3δ−1)/(2δ))2 and a=1−h2a=\sqrt{1-h^{2}}a=1−h2​. Each value is first pulled toward the cloud mean θˉ\bar\thetaθˉ by the factor aaa, and then jittered by noise with variance h2Vh^{2}Vh2V, where VVV is the cloud variance. A smaller δ\deltaδ means more jitter.

Numbers for Liu-West and for SPYWith δ=0.95\delta=0.95δ=0.95: (3δ−1)/(2δ)=0.9737(3\delta-1)/(2\delta)=0.9737(3δ−1)/(2δ)=0.9737, so h2=1−0.97372=0.0519h^{2}=1-0.9737^{2}=0.0519h2=1−0.97372=0.0519 and a=0.9737a=0.9737a=0.9737. A particle with θ=0.90\theta=0.90θ=0.90 in a cloud with mean 0.970.970.97 is pulled to 0.9737×0.90+0.0263×0.97=0.9020.9737\times0.90+0.0263\times0.97=0.9020.9737×0.90+0.0263×0.97=0.902. If the cloud variance is V=0.0004V=0.0004V=0.0004, the jitter has variance 0.0519×0.00040.0519\times0.00040.0519×0.0004 and standard deviation 0.00460.00460.0046. On SPY, the stochastic-volatility log-likelihood over a grid peaks at φ=0.98\varphi=0.98φ=0.98, σ=0.25\sigma=0.25σ=0.25 with 17,79317{,}79317,793, against 16,25216{,}25216,252 for a constant volatility. Its BIC with 333 numbers, −2×17,793.1+3ln⁡5404=−35,560-2\times17{,}793.1+3\ln5404=-35{,}560−2×17,793.1+3ln5404=−35,560, beats the 3-state hidden Markov model (−35,485-35{,}485−35,485) and even the 4-state one (−35,557-35{,}557−35,557).
  • Likelihood by filtering: the sum of the logs of the average weights, with the same random numbers for every choice.
  • Parameters in the state: needs a small jitter after resampling, or the parameter cloud collapses.
  • Compare models fairly: a log-likelihood needs a penalty for the number of parameters, such as the BIC.

Lab · what's graded

  • The log-likelihood gain10 pts
  • The Liu-West constant h squared15 pts
  • The shrinkage factor a10 pts
  • A shrunk particle15 pts
  • The jitter size10 pts
  • A BIC15 pts
  • Parameters without jitter10 pts
  • Why compare with a gap of about 315 pts
0/ 8 answered
Tasks
1Numeric answer10 ptsNot answered

On SPY the best stochastic-volatility log-likelihood is 17,793.117{,}793.117,793.1 and a constant volatility gives 16,251.816{,}251.816,251.8. What is the gain, to the nearest whole number?

g=g =g=accepted: ± 2
2Numeric answer15 ptsNot answered

With δ=0.95\delta=0.95δ=0.95, compute h2=1−((3δ−1)/(2δ))2h^{2}=1-\big((3\delta-1)/(2\delta)\big)^{2}h2=1−((3δ−1)/(2δ))2. Give four decimals.

h2=h2 =h2=accepted: ± 0.0003
3Numeric answer10 ptsNot answered

With h2=0.0519h^{2}=0.0519h2=0.0519, what is a=1−h2a=\sqrt{1-h^{2}}a=1−h2​? Give four decimals.

a=a =a=accepted: ± 0.0003
4Numeric answer15 ptsNot answered

A particle has θ=0.90\theta=0.90θ=0.90, the cloud mean is θˉ=0.97\bar\theta=0.97θˉ=0.97 and a=0.9737a=0.9737a=0.9737. What is the shrunk value a θ+(1−a) θˉa\,\theta+(1-a)\,\bar\thetaaθ+(1−a)θˉ before any jitter? Give three decimals.

t=t =t=accepted: ± 0.001
5Numeric answer10 ptsNot answered

The jitter has variance h2V=0.0519×0.0004=0.0000208h^{2}V=0.0519\times0.0004=0.0000208h2V=0.0519×0.0004=0.0000208. What is its standard deviation? Give four decimals.

s=s =s=accepted: ± 0.0002
6Numeric answer15 ptsNot answered

The stochastic-volatility model has k=3k=3k=3 numbers, a log-likelihood of 17,793.117{,}793.117,793.1 and n=5404n=5404n=5404 returns. Compute −2log⁡L+kln⁡n-2\log L+k\ln n−2logL+klnn with ln⁡5404=8.595\ln5404=8.595ln5404=8.595. Give one decimal.

bic=bic =bic=accepted: ± 1
7Choice10 ptsNot answered

Each particle carries its own parameter value, but the values are never moved after resampling. What happens over time?

8Explain in words15 ptsNot answered

Two settings give particle-filter log-likelihoods 17,793.117{,}793.117,793.1 and 17,789.317{,}789.317,789.3 for φ=0.98\varphi=0.98φ=0.98 and φ=0.99\varphi=0.99φ=0.99. In one or two sentences, explain why you should not conclude that 0.980.980.98 is truly better.

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