σμ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
  • 日本語
  • 中文
Time Series skill›Module 1 · Stationarity and memory›Topic 1.1·~50 minIntermediate

Stationarity and differencing

Skill positionModule 1 of 5 · Topic 1 of 3
1.1 Stationarity and differencing
—Lab score— / 100Total XP—Streak—

What stationary means

A time series is weakly stationary when its mean and variance do not change with time and the covariance between xtx_txt​ and xt+hx_{t+h}xt+h​ depends only on the lag hhh. Such a series keeps coming back to the same level and spreads out by the same amount, so what you estimate from one stretch of it is valid for the next. Daily returns are close to stationary. Prices are not: they wander, and the longer you watch them the farther they can be from where they started.

E[xt]=μ,Var(xt)=σ2,Cov(xt,xt+h)=γ(h);Δxt=xt−xt−1,rt=ln⁡Pt−ln⁡Pt−1E[x_t]=\mu,\qquad \mathrm{Var}(x_t)=\sigma^{2},\qquad \mathrm{Cov}(x_t,x_{t+h})=\gamma(h);\qquad \Delta x_t=x_t-x_{t-1},\qquad r_t=\ln P_t-\ln P_{t-1}E[xt​]=μ,Var(xt​)=σ2,Cov(xt​,xt+h​)=γ(h);Δxt​=xt​−xt−1​,rt​=lnPt​−lnPt−1​(1)

The standard model of a non-stationary price is the random walk xt=xt−1+εtx_t=x_{t-1}+\varepsilon_txt​=xt−1​+εt​: each step is a fresh shock, and the shocks add up, so the variance after ttt steps is tσ2t\sigma^{2}tσ2 and grows without limit. Differencing turns it into the stationary series Δxt=εt\Delta x_t=\varepsilon_tΔxt​=εt​. A series that becomes stationary after one difference is called integrated of order one, written I(1)I(1)I(1). If a series is instead a deterministic trend plus stationary noise, the right fix is to subtract the fitted trend, and differencing would only add noise. Do not difference more often than needed: a series that was already stationary becomes over-differenced, with a negative autocorrelation that was not there before.

Differencing five pricesTake the prices 100, 102, 101, 105, 104100,\,102,\,101,\,105,\,104100,102,101,105,104. The differences are 2, −1, 4, −12,\,-1,\,4,\,-12,−1,4,−1, with mean 1.01.01.0. The level moved a lot, but the differences stay in a narrow band around a constant, which is what a stationary series looks like. The log return from 100 to 102 is ln⁡(1.02)≈0.0198\ln(1.02)\approx0.0198ln(1.02)≈0.0198, close to the simple return of 2%2\%2% for small moves.
  • Weak stationarity: constant mean and variance, and an autocovariance that depends only on the lag.
  • Differencing removes a stochastic trend; detrending removes a deterministic one.
  • Spurious regression: two unrelated random walks regressed on each other often show a high R2R^2R2 and a significant slope.

Lab · what's graded

  • The mean of the differences15 pts
  • A log return15 pts
  • How far a random walk wanders15 pts
  • Spot the stationary series15 pts
  • Match the vocabulary15 pts
  • Checking a series before modelling10 pts
  • Why a regression can mislead15 pts
0/ 7 answered
Tasks
1Numeric answer15 ptsNot answered

A price series is 100, 103, 101, 106, 110100,\,103,\,101,\,106,\,110100,103,101,106,110. What is the mean of its first differences Δxt\Delta x_tΔxt​?

mean=mean =mean=accepted: ± 0.01
2Numeric answer15 ptsNot answered

A price rises from 100 to 110. What is the log return ln⁡(110/100)\ln(110/100)ln(110/100)? Give it to four decimals.

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

A random walk xt=xt−1+εtx_t=x_{t-1}+\varepsilon_txt​=xt−1​+εt​ has independent shocks with standard deviation 222. What is the standard deviation of x25−x0x_{25}-x_0x25​−x0​?

sd=sd =sd=accepted: ± 0.05
4Choice15 ptsNot answered

Which of these series is closest to stationary?

5Match15 ptsNot answered

Match each term with its meaning.

Pick the partner of each item on the left.

Random walk
Integrated of order one
Over-differencing
Trend-stationary
6Order the steps10 ptsNot answered

Put the steps in order.

Drag to reorder, or focus an item, press Space to lift it, the arrow keys to move it and Space to drop it.

  1. 1Fit the model on the stationary series
  2. 2Look for a trend or a changing spread
  3. 3Plot the series
  4. 4Difference or detrend, then check again
7Explain in words15 ptsNot answered

In one or two sentences, explain why regressing one stock's price level on another stock's price level can give a high R2R^2R2 even when the two have nothing to do with each other.

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