time series fitting to statistical moments

1 visualizzazione (ultimi 30 giorni)
Paolo
Paolo il 14 Feb 2025
Risposto: Star Strider il 14 Feb 2025
Hello,
I have a process for which I know the conditional moments:
mean = exp(-a * t)*(x-mu)
variance = ((1-exp(-2* t* a))* sigma)/2a
where a and sigma are unknown parameters.
By using the fact that conditional moments are linear, I would like to estimate the 2 unknown parameters through a linear regression of X(t+dt) and X^2(t+dt) on X(t) where X(t) is a known time series that I have, and dt is the time interval used in the time series.
Any idea about how to implement this in matlab code, would be really appreciated.
Thanks
Best regards
Paolo
  2 Commenti
Sam Chak
Sam Chak il 14 Feb 2025
Hi @Paolo, could you at least provide the data for visualization in MATLAB?
Paolo
Paolo il 14 Feb 2025
Hi Sam, here the data attached.
thanks for help
Paolo

Accedi per commentare.

Risposte (1)

Star Strider
Star Strider il 14 Feb 2025
where a and sigma are unknown parameters
Beyond that, I am clueless as to any appropriate way to do this parameter estimation, since there is a significant amount of missing information.
Using my fertile imagination to fill those gaps, try something like tthis —
LD = load('cds.mat');
X = LD.spread; % The ‘X’ Part
X = X(:);
Size_X = size(X)
Size_X = 1×2
2219 1
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
t = 0:numel(X)-1; % Undefined, So A Guess
t = t(:);
mu = mean(X) % Undefined, So A Guess
mu = 0.0425
dt = randi([2 10])
dt = 4
Xmm = movmean(X,dt); % Use ‘movmean’ To Provide The ‘(X(t+dt)’ Mean
Xmv = movvar(X,dt); % Use ‘movvar’ To Provide The ‘(X(t+dt)’ Variance
fcn = @(b,x) [exp(-b(1) .* t).*(x-mu), ((1-exp(-2 * t .* b(1)) .* b(2))./(2*b(1)))] % b(1) = a, b(2) = sigma
fcn = function_handle with value:
@(b,x)[exp(-b(1).*t).*(x-mu),((1-exp(-2*t.*b(1)).*b(2))./(2*b(1)))]
[B, fv] = fminsearch(@(b) norm([Xmm(:) Xmv(:)] - fcn(b,X(:))), rand(2,1) );
FinalValue = fv
FinalValue = 2.1505
fprintf('\n\nParameters:\n\ta \t= %10.3f\n\tsigma \t= %10.3f\n\n', B)
Parameters: a = 2782.231 sigma = 2162.584
figure
plot(t, X, DisplayName="X(t)")
hold on
plot(t, Xmm, DisplayName="movmean(X)")
hold off
grid
xlabel("Time")
ylabel("Value")
legend(Location='best')
X = X.^2; % The 'X²' Part
Xmm = movmean(X,dt); % Use ‘movmean’ To Provide The ‘(X(t+dt)’ Mean
Xmv = movvar(X,dt); % Use ‘movvar’ To Provide The ‘(X(t+dt)’ Variance
fcn = @(b,x) [exp(-b(1) .* t).*(x-mu), ((1-exp(-2 * t .* b(1)) .* b(2))./(2*b(1)))] % b(1) = a, b(2) = sigma
fcn = function_handle with value:
@(b,x)[exp(-b(1).*t).*(x-mu),((1-exp(-2*t.*b(1)).*b(2))./(2*b(1)))]
[B, fv] = fminsearch(@(b) norm([Xmm(:) Xmv(:)] - fcn(b,X(:))), rand(2,1) );
FinalValue = fv
FinalValue = 0.1420
fprintf('\n\nParameters:\n\ta \t= %10.3f\n\tsigma \t= %10.3f\n\n', B)
Parameters: a = 525.128 sigma = 109.864
figure
plot(t, X, DisplayName="X(t)^2")
hold on
plot(t, Xmm, DisplayName="movmean(X^2)")
hold off
grid
xlabel("Time")
ylabel("Value")
legend(Location='best')
.

Categorie

Scopri di più su Linear and Nonlinear Regression in Help Center e File Exchange

Prodotti


Release

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by