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

7 ビュー (過去 30 日間)
Mingyang Sun
Mingyang Sun 2023 年 7 月 12 日
編集済み: Pranavkumar Mallela 2023 年 7 月 27 日
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 月 12 日
編集済み: 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 Center および File ExchangeLinear 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