time series fitting to statistical moments
Show older comments
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 Comments
Paolo
on 14 Feb 2025
Answers (1)
‘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)
t = 0:numel(X)-1; % Undefined, So A Guess
t = t(:);
mu = mean(X) % Undefined, So A Guess
dt = randi([2 10])
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
[B, fv] = fminsearch(@(b) norm([Xmm(:) Xmv(:)] - fcn(b,X(:))), rand(2,1) );
FinalValue = fv
fprintf('\n\nParameters:\n\ta \t= %10.3f\n\tsigma \t= %10.3f\n\n', B)
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
[B, fv] = fminsearch(@(b) norm([Xmm(:) Xmv(:)] - fcn(b,X(:))), rand(2,1) );
FinalValue = fv
fprintf('\n\nParameters:\n\ta \t= %10.3f\n\tsigma \t= %10.3f\n\n', B)
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')
.
Categories
Find more on Data Preprocessing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
