σμ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
  • 日本語
  • 中文
statsmodels skill›Module 2 · Models for time series›Topic 2.3·~55 minAdvanced

SARIMAX forecasts judged out of sample

Skill positionModule 2 of 3 · Topic 3 of 9
2.3 SARIMAX forecasts judged out of sample
—Lab score— / 100Total XP—Streak—

A forecast is only as good as its test

An ARIMA(p,d,q) model explains a series yₜ from its own past and from past shocks, after differencing d times: with d=0, an AR(1) is yₜ=c+φ yₜ₋₁+eₜ, which is mean-reverting when |φ|<1 and has the long-run mean μ=c/(1-φ). SARIMAX(y, order=(p, d, q), trend='c') fits it by maximum likelihood; trend='c' adds the constant, which makes sense only when d=0 (a differenced series has no level to return to). The fitted object gives params, aic and get_forecast(steps). The AIC =2k-2ln L trades fit against the number of parameters k; among candidates fitted to the same data, the lowest AIC is preferred, but only a difference of a few points means anything. For monthly log volatility of SPY, an ARMA(1,1) (AIC 271.9) and an AR(2) (272.7) edge out the AR(1) (275.0), and differencing is far worse (290.5).

In-sample fit says little about forecasting. The honest test is a rolling origin: at each origin t₀, fit on y_1..t₀ only, forecast h steps ahead, and compare with the value that actually came, y_(t₀+h). Collect the errors and score them with the RMSE, √(mean(e²)). Always include baselines: the naive forecast (the last value) and the historical mean. The skill 1-RMSE_model/RMSE_baseline is positive when the model wins. Here, one month ahead the AR(1) has an RMSE of 0.373 against 0.451 (naive) and 0.419 (mean): skill 0.17 and 0.11. Twelve months ahead its RMSE is 0.526, identical to the mean's, and its skill over the naive forecast (0.34) comes only from the naive forecast's failure: the AR(1) forecast has simply decayed to the mean, from -2.09 to -2.01. Knowing how fast a forecast reverts to the mean tells you how far ahead the model knows anything.

  • Constant only without differencing; compare candidate orders by AIC and trust only gaps of a few points.
  • Rolling origin: refit at each origin on past data only; never score a forecast on data the fit saw.
  • Always beat a baseline: the naive forecast and the historical mean; skill 1-RMSEₘ/RMSE_b.

Lab · what's graded

  • The SARIMAX fit10 pts
  • Point forecasts10 pts
  • Comparing orders15 pts
  • Rolling-origin errors25 pts
  • The RMSE5 pts
  • Forecast skill10 pts
  • The volatility study25 pts
Explorer · lab-sx-16
▾ lab-sx-16
▾ data
…
bash · in-browser
learner@quantcraft:~/lab-sx-16$
Python not loaded yetPythonLn 1, Col 1Spaces: 4UTF-8

Reset this topic?

Everything in lab-sx-16 goes back to the starter files and the terminal is cleared. Your current solution will be lost — this can't be undone.

Will be reset
  • main.py → starter code
  • Terminal history and test output
  • Unsubmitted changes
Will be kept
  • Best lab score
  • Your XP and streak
  • Lecture progress and notes

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