ARIMA BIC LOOP including "zero"
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
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 Commenti
Risposta accettata
Brendan Hamm
il 30 Nov 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Conditional Variance Models in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!