Estimating the decay parameter in Exponentially Weighted Moving Average (EWMA) model
7 views (last 30 days)
Show older comments
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.
0 Comments
Answers (1)
Pranavkumar Mallela
on 12 Jul 2023
Edited: Pranavkumar Mallela
on 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
% 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!
0 Comments
See Also
Categories
Find more on Linear and Nonlinear Regression 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!