Schwartz-Smith model using SSM

1 次查看(过去 30 天)
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

采纳的回答

Parag
Parag 2025-4-15
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!

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Risk Management Toolbox 的更多信息

产品


版本

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by