Function to find ar coefficients using Least squres

Hi,
Can someone help me write a FUNCTION to estimate AR(p) coefficients using LEAST SQUARES?
Thanks

4 件のコメント

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 24 日
Give an example
dav
dav 2013 年 2 月 24 日
編集済み: dav 2013 年 2 月 24 日
I am new to writing functions. If I have data set called y, I need to write a function to get the coefficients after fitting an AR(15) model to y
Thanks
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 24 日
What is AR(15)?
dav
dav 2013 年 2 月 24 日
Auto Regressive model of order 15.
Thanks

サインインしてコメントする。

 採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 24 日
編集済み: Azzi Abdelmalek 2013 年 2 月 24 日

1 投票

Construct your measure matrix Fi,
yourcoeff=FI\y
Example
% y(n)=a1 y(n-1)+a2 y(n-2)+ a3 y(n-3) your system
% if y=[1 2 3 4 5 6 7 8 9 10]
y= [4;5;6;7] % Using 4 samples
FI=[3 2 1 % measure matrix
4 3 2
5 4 3
6 5 4]
% coeff=[a1;a2;a3] coefficients to find
coeff=FI\y

3 件のコメント

dav
dav 2013 年 2 月 25 日
thanks. this is nice. Can u give an example to estimate arma parameter also but with the condition that parameter should be positive.
Azzi Abdelmalek
Azzi Abdelmalek 2013 年 2 月 25 日
Give an example of your model.
dav
dav 2013 年 2 月 27 日
Here is the code that generates some data. I need to fit an arma model to yt1 and get the coef. estimates with that condition that paremeter estimates are positive.
lc; clear;
m=160; n=10;
ftyPI=zeros(10,100); fsigPI=zeros(10,100);
Lbyth=zeros(10,100); Lbsigh=zeros(10,100);
mccounty =zeros(10,100); mccountsig =zeros(10,100);
for mc= 1:100
a0 = 0.05; a1 = 0.1; b1 = 0.85;
epsi=zeros(3000,1); simsig=zeros(3000,1);
for i = 1:3000 if (i==1) simsig(i) = a0 ; s=(simsig(i))^0.5; epsi(i) = normrnd(0,1) * s; else simsig(i) = a0+ a1*(epsi(i-1))^2+ b1*simsig(i-1); s=(simsig(i))^0.5; epsi(i) = normrnd(0,1) * s; end end
yt1=epsi.^2;

サインインしてコメントする。

その他の回答 (0 件)

タグ

タグが未入力です。

Community Treasure Hunt

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

Start Hunting!

Translated by