Can you help me fix this?

조회 수: 1 (최근 30일)
dav
dav 2013년 2월 25일
Im using the following function
function beta = arima(y, p, q, C, sigma)
if nargin < 4
C = 0;
end
if nargin < 5
sigma = 1;
end
y = y(:);
N = length(y);
e = sigma * randn(N, 1);
Y = y - e;
% By = y(1:end-1) y(1:end-2) ... y(:, end-p)
By = arrayfun(@(j) [zeros(j,1); y(1:end-j)], 1:p, 'UniformOutput' , false); By = [By{:}];
Be = arrayfun(@(j) [zeros(j,1); e(1:end-j)], 1:q, 'UniformOutput' , false); Be = [Be{:}];
if C == 0
cvec = [];
else
cvec = ones(N,1);
end
X = [cvec By Be];
x1 = X(any(X,2),:);
beta = lsqnonneg (x1, Y);
end
*In the following code*
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;
beta = arima(yt1, 1, 1, 1, 1);
I expect to get
Constant estimate close to 0.05
ar parameter estimate close to 0.95
and ma parameter estimate close to 0.85
However, I am not getting the results .. Can someone fix this please?
  댓글 수: 5
dav
dav 2013년 2월 27일
what tags should I put when I need help with just matlab coding then?
Thanks

댓글을 달려면 로그인하십시오.

답변 (1개)

Jan
Jan 2013년 2월 27일
Of course we cannot fix your function, because we do not know, what you are wanting to calculate. All we have is the code, which might contain a bug anywhere, and the the expected result. But this is not enough information to locate a bug.
Perhaps this simplified questions reveals the core of the problem of your question:
I have two values a=9 and b=10. I add them: |c = a + b| and get 19. But I want to get 20. Please fix the code.
There is an infinite number of possible modifications and based on the given information, it is not possible to decide for a specific one. Ok?

카테고리

Help CenterFile Exchange에서 Linear Algebra에 대해 자세히 알아보기

태그

아직 태그를 입력하지 않았습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by