how to generate error terms for idploy or ARMAX models

5 次查看(过去 30 天)
Dear Experts,
I would like to convert ARMAX model of idploy form to classical time series equation as given below.
y(t)=[a1 a2 .... an]*[y(t−1)+y(t-2)+...+y(t−n)] + [b1 b2 .... bn]*[u(t−1)+u(t-2)+...+u(t−n)] + [c1 c2 .... cn]*[e(t−1)+e(t-2)+...+e(t−n)] + e(t)
As idploy provides a1...an, b1....bn and c1... cn, please let me know how to generate e(t−1), e(t-2),...,e(t−n)],e(t) terms
Thanking you in advance,
Kind Regards, Kushan

回答(1 个)

Jaynik
Jaynik 2024-7-15,6:59
Hi Kushan,
In the context of an ARMAX model, the terms in the equation are the residuals of the model, that is, the differences between the observed and predicted values of the output variable y(t).
Once you have estimated the ARMAX model using the idpoly function, Generate iddata object using the input u(t) and the output y(t). Then you can generate the residuals using the resid function. Following is a sample code for the same:
% Assume model is your estimated ARMAX model
% Assume y and u are your output and input data
z = iddata(y, u);
% Compute the residuals
residuals = resid(model, z);
% e.OutputData now contains the residuals e(t), e(t-1), ..., e(t-n)
The residuals are returned as an iddata object, and can be accessed through the residuals themselves with the OutputData property of this object.
Please note that the residuals e(t), e(t-1), …, e(t-n) are typically assumed to be white noise. They are normally distributed with zero mean and constant variance, and are uncorrelated with each other and with the input data u(t), u(t-1), …, u(t-n).
If you want to manually compute the output of the model using the ARMAX equation, you can refer the following code:
e = residuals.OutputData;
% Extract coefficients
a = model.A(2:end); % AR coefficients (excluding leading 1)
b = model.B(2:end); % MA coefficients (excluding leading 0)
c = model.C(2:end); % Noise coefficients (excluding leading 1)
y = zeros(N, 1);
for t = (max(length(a), length(b), length(c)) + 1):N
y(t) = -a * y(t-1:-1:t-length(a))' + b * u(t-1:-1:t-length(b))' + c * e(t-1:-1:t-length(c))' + e(t);
end
Hope this helps!

类别

Help CenterFile Exchange 中查找有关 Preprocess Data 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by