σμ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.2·~50 minAdvanced

Model comparison and Bayes factors

Skill positionModule 3 of 3 · Topic 2 of 4
3.2 Model comparison and Bayes factors
—Lab score— / 100Total XP—Streak—

Which model explains the data better?

Often you must choose between two ideas about the world. Say model M0M_0M0​ claims a strategy wins exactly half of the days, θ=0.5\theta=0.5θ=0.5. Model M1M_1M1​ allows any win rate, with a flat prior. Each model gets a score: the marginal likelihood P(D∣M)P(D\mid M)P(D∣M), the probability it gave to the data you actually saw, averaged over its own prior. The ratio of the two scores is the Bayes factor BF10=P(D∣M1)/P(D∣M0)BF_{10}=P(D\mid M_1)/P(D\mid M_0)BF10​=P(D∣M1​)/P(D∣M0​). It tells how much the data favour M1M_1M1​. Multiply it by the prior odds to get posterior odds.

P(D∣M)=∫P(D∣θ) p(θ∣M) dθ,BF10=P(D∣M1)P(D∣M0),P(M1∣D)P(M0∣D)=P(M1)P(M0)⋅BF10P(D\mid M)=\int P(D\mid\theta)\,p(\theta\mid M)\,d\theta,\qquad BF_{10}=\frac{P(D\mid M_1)}{P(D\mid M_0)},\qquad \frac{P(M_1\mid D)}{P(M_0\mid D)}=\frac{P(M_1)}{P(M_0)}\cdot BF_{10}P(D∣M)=∫P(D∣θ)p(θ∣M)dθ,BF10​=P(D∣M0​)P(D∣M1​)​,P(M0​∣D)P(M1​∣D)​=P(M0​)P(M1​)​⋅BF10​(1)

Two things make Bayes factors different from simply picking the model that fits best. First, they punish complexity without any extra rule. A flexible model spreads its prior over many possible outcomes, so each one gets little probability, and it wins only if the data fit well enough to make up for that. Second, they depend on the prior, so a very wide prior on M1M_1M1​ is punished more. As a rough scale, a factor between 111 and 333 is barely worth mentioning, 333 to 101010 is moderate, 101010 to 100100100 is strong, and above 100100100 is decisive.

14 wins in 20 days, then 70 in 100With 141414 wins in 202020 days, M0M_0M0​ gives (2014)0.520=0.0370\binom{20}{14}0.5^{20}=0.0370(1420​)0.520=0.0370. M1M_1M1​ with a flat prior gives 1/(n+1)=1/21=0.04761/(n+1)=1/21=0.04761/(n+1)=1/21=0.0476. The Bayes factor is 1.291.291.29, hardly any evidence, and with equal prior odds P(M1∣D)=1.29/2.29=0.56P(M_1\mid D)=1.29/2.29=0.56P(M1​∣D)=1.29/2.29=0.56. With 707070 wins in 100100100 days, M0M_0M0​ gives 2.3×10−52.3\times10^{-5}2.3×10−5 and M1M_1M1​ gives 1/101=0.00991/101=0.00991/101=0.0099. The factor is about 427427427: decisive. The same win rate of 70%70\%70% is far more convincing with more days.
  • Marginal likelihood: the probability a model gave to the data, averaged over its own prior.
  • Bayes factor: ratio of two marginal likelihoods. Posterior odds equal prior odds times it.
  • Built-in Occam's razor: flexible models spread their prior thin and need the data to pay for it.

Lab · what's graded

  • The fixed model15 pts
  • The flexible model15 pts
  • The Bayes factor15 pts
  • The posterior probability15 pts
  • Reading a factor of 42715 pts
  • Match the vocabulary10 pts
  • Why complexity is punished15 pts
0/ 7 answered
Tasks
1Numeric answer15 ptsNot answered

M0M_0M0​ says the win rate is exactly 0.50.50.5. What probability does it give to 141414 wins in 202020 days, (2014) 0.520\binom{20}{14}\,0.5^{20}(1420​)0.520, with (2014)=38760\binom{20}{14}=38760(1420​)=38760? Give four decimals.

m=m =m=accepted: ± 0.0005
2Numeric answer15 ptsNot answered

M1M_1M1​ allows any win rate with a flat prior. For kkk wins in nnn days it gives the probability 1/(n+1)1/(n+1)1/(n+1) whatever kkk is. What is it for n=20n=20n=20? Give four decimals.

m=m =m=accepted: ± 0.0005
3Numeric answer15 ptsNot answered

What is the Bayes factor BF10=P(D∣M1)/P(D∣M0)BF_{10}=P(D\mid M_1)/P(D\mid M_0)BF10​=P(D∣M1​)/P(D∣M0​) from the two numbers above, 0.0476/0.03700.0476/0.03700.0476/0.0370? Give two decimals.

b=b =b=accepted: ± 0.02
4Numeric answer15 ptsNot answered

With equal prior odds, the posterior odds equal the Bayes factor 1.291.291.29. What is the posterior probability of M1M_1M1​, 1.29/(1+1.29)1.29/(1+1.29)1.29/(1+1.29)? Give three decimals.

p=p =p=accepted: ± 0.004
5Choice15 ptsNot answered

With 70 wins in 100 days the Bayes factor for the flexible model is about 427. How strong is that evidence?

6Match10 ptsNot answered

Match each term with its meaning.

Pick the partner of each item on the left.

Marginal likelihood
Bayes factor
Built-in Occam penalty
Posterior odds
7Explain in words15 ptsNot answered

In one or two sentences, explain why a Bayes factor automatically penalises a more flexible model.

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