Schwartz-Smith model using SSM

5 Ansichten (letzte 30 Tage)
Todd
Todd am 18 Apr. 2024
Beantwortet: Parag am 15 Apr. 2025
I am looking to use the Schwartz-Smith code here, but adapt the Kalman filter function to use SSM. I haven't been able to find anything to guide me, so I am hoping there might be some hints. Thank you

Akzeptierte Antwort

Parag
Parag am 15 Apr. 2025
Hi @Todd,
The Schwartz-Smith 2-factor model decomposes the log spot price of a commodity into two components:
  • Long-term equilibrium level (non-stationary, modelled as Brownian motion with drift)
  • Short-term deviations (mean-reverting component)
The original code uses a custom Kalman filter for parameter estimation and filtering. To adapt this into MATLAB's SSM (State-Space Model) framework, the model needs to be expressed in the standard linear Gaussian state-space form:
SSM Formulation Overview
State Equation:
Let the state vector be:
xt=[χt
ξt]
  • χt ​: long-term (non-stationary)
  • ξt: short-term (mean-reverting)
The dynamics are:
χt+1=χt+μ+ηt
​ξt+1​​=χt​+μ+ηt​=ϕξt​+ϵt​​
where ηtN(0,ση2) and ϵtN(0,σϵ2)
Observation Equation:
yt=χttt , εtN(0,σε2)
Please refer the MATLAB pseudo-code for the same:
% Define state-space model for Schwartz-Smith
% Parameters: mu, phi, sigma_eta, sigma_eps, sigma_obs
A = @(params) [1 0; 0 params(2)]; % phi
B = @(params) [1; 0]; % mu only affects chi_t
C = @(params) [1 1]; % observation: chi + xi
D = @(params) eye(2) .* [params(3); params(4)]; % process noise
E = @(params) params(5); % observation noise
% Define ssm object
ssmModel = ssm(...
@(params) deal(A(params), B(params) * params(1), C(params), E(params), D(params) * D(params)'));
% Initial parameter guess: [mu, phi, sigma_eta, sigma_eps, sigma_obs]
param0 = [0.1, 0.9, 0.1, 0.1, 0.1];
% Load your observed log spot price time series
% y = logPrices;
% Estimate parameters
[estModel, estParams, estSE] = estimate(ssmModel, logPrices, param0);
Please refer these MATLAB documentations for more details:
Hope this is beneficial!

Weitere Antworten (0)

Kategorien

Mehr zu Risk Management Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by