ARIMA BIC LOOP including "zero"
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
polar
el 30 de Nov. de 2016
Comentada: Brendan Hamm
el 30 de Nov. de 2016
Hi, I found a script aimed to find the best arima(p,0,d) model as the one with the lowest BIC(or AIC) value in order to use a trading strategy based on ARIMA/GARCH model.
Here I report the code found (including my data):
Currency=xlsread('EURUSD.xls','exchange','A:B');
eur=Currency;
LOGL = zeros(4,4);
PQ = zeros(4,4);
for p = 1:4
for q = 1:4
mod = arima(p,0,q);
[fit,~,logL] = estimate(mod,eur,'print',false);
LOGL(p,q) = logL;
PQ(p,q) = p+q;
end
end
LOGL = reshape(LOGL,16,1);
PQ = reshape(PQ,16,1);
[~,bic] = aicbic(LOGL,PQ+1,100);
reshape(bic,4,4)
Ok, it works but in my case, I had already found out that an ARIMA (1,0,0) was the best fit,so my target is to include the "zero" value for "p" or "q" for future needs. The problem is that when p AND q are both zero, it clearly shows error. So I started using "continue" to skip the arima(0,0,0) and compute all other ones but...I always failed (I'm very poor in programming). If someone can help me.... ps: I'm helping myself with a "R" script but obviously I'm using Matlab :-)
0 comentarios
Respuesta aceptada
Brendan Hamm
el 30 de Nov. de 2016
If you changed the loop to start at 0, you are trying to index LOGL and PQ at the index 0 which does not exist. MATLAB starts indexing at 1.
First pre-allocate the additional space:
LOGL = zeros(5,5);
PQ = zeros(5,5);
Error:
for p = 0:4
for q = 0:4
mod = arima(p,0,q);
[fit,~,logL] = estimate(mod,eur,'print',false);
LOGL(p,q) = logL;
PQ(p,q) = p+q;
end
end
So increase the indices by 1.
No Error:
for p = 0:4
for q = 0:4
mod = arima(p,0,q);
[fit,~,logL] = estimate(mod,eur,'print',false);
LOGL(p+1,q+1) = logL; % Index at the next row/col
PQ(p+1,q+1) = p+q; % Index at the next row/col
end
end
Bear in mind that now the log-likelihood of the ARIMA(2,0,3) model is in LOGL(3,4)
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Conditional Variance Models en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!