Can you help me fix this?

1 visualización (últimos 30 días)
dav
dav el 25 de Feb. de 2013
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 comentarios
dav
dav el 27 de Feb. de 2013
what tags should I put when I need help with just matlab coding then?
Thanks

Iniciar sesión para comentar.

Respuestas (1)

Jan
Jan el 27 de Feb. de 2013
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?

Categorías

Más información sobre Linear Algebra en Help Center y File Exchange.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by