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

7 次查看(过去 30 天)
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.

回答(1 个)

Pranavkumar Mallela
编辑:Pranavkumar Mallela 2023-7-27
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!

类别

Help CenterFile Exchange 中查找有关 Linear and Nonlinear Regression 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by