time series fitting to statistical moments

조회 수: 3 (최근 30일)
Paolo
Paolo 2025년 2월 14일
답변: Star Strider 2025년 2월 14일
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
Sam Chak
Sam Chak 2025년 2월 14일
Hi @Paolo, could you at least provide the data for visualization in MATLAB?
Paolo
Paolo 2025년 2월 14일
Hi Sam, here the data attached.
thanks for help
Paolo

댓글을 달려면 로그인하십시오.

답변 (1개)

Star Strider
Star Strider 2025년 2월 14일
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')
.

카테고리

Help CenterFile Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기

제품


릴리스

R2024b

Community Treasure Hunt

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

Start Hunting!

Translated by