Can you help me fix this?

1 visualizzazione (ultimi 30 giorni)
dav
dav il 25 Feb 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 Commenti
dav
dav il 27 Feb 2013
what tags should I put when I need help with just matlab coding then?
Thanks

Accedi per commentare.

Risposte (1)

Jan
Jan il 27 Feb 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?

Categorie

Scopri di più su Linear Algebra in Help Center e File Exchange

Tag

Non è stata ancora inserito alcun tag.

Community Treasure Hunt

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

Start Hunting!

Translated by