Filter löschen
Filter löschen

Estimating the decay parameter in Exponentially Weighted Moving Average (EWMA) model

7 Ansichten (letzte 30 Tage)
Given the data , ; I would like to like to estimate the decay parameter λ in Exponentially Weighted Moving Average (EWMA) model, such that
where is the error term in the nonlinear regression, .
I am wondering, is there any convenient way to estimate the decay parameter λ uisng nonlinear fitting function? Because K could be very large, which around 200.

Antworten (1)

Pranavkumar Mallela
Pranavkumar Mallela am 12 Jul. 2023
Bearbeitet: Pranavkumar Mallela am 27 Jul. 2023
Hi,
As per my understanding, you want to estimate the decay parameter using a non-linear fitting function.
This can be done using the 'fminsearch' function.
Please find the code for the same as follows:
K = 4; % value of K
y = [1 4 8 16 32 64 128 256 512 1024]; % your data
lambda_initial = 0.5; % starting value of lambda
objective = @(lambda) sum((y-EWMA(lambda,y,K)).^2); % function handle of the function to be minimized
lambda_estimated = fminsearch(objective, lambda_initial) % calling fminsearch to find lambda
lambda_estimated = 1.1158
% function to compute the series using the EWMA model
function result = EWMA(lambda,y,K)
N = numel(y);
% result that is fed into the objective function
result = [];
% iterate for each term
for t=1:N
yt = 1;
% iterate for all k <= K
for k=1:K
if t-k <= 0
continue
end
yt = yt + lambda^k * result(t-k);
end
result = [result yt];
end
end
For more information regarding the 'fminsearch' function, please refer to the following documentation: https://www.mathworks.com/help/matlab/ref/fminsearch.html
Hope this helps! Thanks!

Kategorien

Mehr zu Least Squares finden Sie in Help Center und File Exchange

Produkte


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by