time series fitting to statistical moments
조회 수: 3 (최근 30일)
이전 댓글 표시
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
답변 (1개)
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)
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')
.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Linear and Nonlinear Regression에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

