LEAST SQUARES Estimation code
조회 수: 10 (최근 30일)
이전 댓글 표시
Anybody know the code to estimate an ARMA model using LEAST SQUARES?
Thanks.
댓글 수: 0
채택된 답변
Shashank Prasanna
2013년 2월 8일
편집: Shashank Prasanna
2013년 2월 8일
To show you an example I am going to generate some data from the following ARMA model. I am generating this using the ARIMA function in the econometrics toolbox. If you don't have it don't worry because I am using this data to demonstrate how to estimate the coefficients using least squares. How ever I would like to inform you that that a more popular approach is to use MLE.
Generate some data to simulate.
Here AR lag 1, coeff 0.3
MA lag 1, coeff 0.2
rng(5);
simModel = arima('AR',0.3,'MA',0.2,'Constant',0,'Variance',1);
% simModel = arima('AR',0.4,'Constant',0,'Variance',1);
Y = simulate(simModel,500);
The following code will estimate the coefficients using least squares using MATLAB's \ operator.
>> rng(5);
inn=randn(500,1);
[Y -[0;Y(1:end-1)] -[0;inn(1:end-1)]]\inn
ans =
1.0000
0.3000
0.2000
The first number is for y(t) which is 1. the AR is 0.3 and MA is 0.2.
댓글 수: 3
Shashank Prasanna
2013년 2월 8일
RNG is used to set the random number generator seed, it could be anything, i just used 5. Notice that I reuse it again while I estimate so that I use the exact same random numbers during estimation that I used during data generation.
inn is commonly known as innovations or error terms, and it is assumed to be white noise or normally distributed with 0 mean 1 var, but could be something else. i use the randn function to generate some inn. The equation I used is just the solution to a linear system Ax=b which can be solved in MATLAB for x by performing A\b.
I would suggest any starting with MATLAB documentation: http://www.mathworks.com/help/matlab/ref/rng.html http://www.mathworks.com/help/econ/specification-1-1.html
Lastly, MLE is indeed a popular mathod and MATLAB is capable to solving MLEs as long as you formulate you problem that way. search documentation for MLE
hth
추가 답변 (1개)
Azzi Abdelmalek
2013년 2월 7일
댓글 수: 4
Azzi Abdelmalek
2013년 2월 7일
편집: Azzi Abdelmalek
2013년 2월 7일
% n: is the order of your system
% u: input signal
% y : output signal
k1=5 % k1 >n
k2=30
teta=least_square(u,y,n,k1,k2)
yem
2014년 12월 16일
hi i need to identify systems with 2 delays with least square algorithm anyhelp please
참고 항목
카테고리
Help Center 및 File Exchange에서 GARCH Model에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!