Help: Code for Automating ARMA Identification in Matlab - Matlab, R project and Python | futures io social day trading
futures io futures trading

Help: Code for Automating ARMA Identification in Matlab
Updated: Views / Replies:6,135 / 3
Created: by Oxymoron Attachments:0

Welcome to futures io.

(If you already have an account, login at the top of the page)

futures io is the largest futures trading community on the planet, with over 100,000 members. At futures io, our goal has always been and always will be to create a friendly, positive, forward-thinking community where members can openly share and discuss everything the world of trading has to offer. The community is one of the friendliest you will find on any subject, with members going out of their way to help others. Some of the primary differences between futures io and other trading sites revolve around the standards of our community. Those standards include a code of conduct for our members, as well as extremely high standards that govern which partners we do business with, and which products or services we recommend to our members.

At futures io, our focus is on quality education. No hype, gimmicks, or secret sauce. The truth is: trading is hard. To succeed, you need to surround yourself with the right support system, educational content, and trading mentors Ė all of which you can find on futures io, utilizing our social trading environment.

With futures io, you can find honest trading reviews on brokers, trading rooms, indicator packages, trading strategies, and much more. Our trading review process is highly moderated to ensure that only genuine users are allowed, so you donít need to worry about fake reviews.

We are fundamentally different than most other trading sites:
  • We are here to help. Just let us know what you need.
  • We work extremely hard to keep things positive in our community.
  • We do not tolerate rude behavior, trolling, or vendors advertising in posts.
  • We firmly believe in and encourage sharing. The holy grail is within you, we can help you find it.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community.  It's free and simple.

-- Big Mike, Site Administrator

Thread Tools Search this Thread

Help: Code for Automating ARMA Identification in Matlab

  #1 (permalink)
Posts: 7 since Apr 2010
Thanks: 10 given, 5 received

Help: Code for Automating ARMA Identification in Matlab

I'm a college student from India and a noob to matlab. I've been trying my hand at writing programs in matlab and started with this simple ARMA model:

load NiftyFutStationary.mat;
for AR = 1:10
for MA = 1:10
Y = aic(armax(CloseD,[AR,MA]));

I want Y to return a column matrix of the Akaike values for each AR-MA combination rather than just a single final value. How do I achieve this? Thanks a lot for your help!

Reply With Quote
  #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.

  #3 (permalink)
Posts: 7 since Apr 2010
Thanks: 10 given, 5 received

NVM, got it:

load NiftyFutStationary.mat;
Y = [];
for AR = 1:10
for MA = 1:10
Y = [Y; aic(armax(CloseD,[AR,MA])),AR,MA];
clear AR MA
AR = Y(:,2);
MA = Y(:,3);
AIC = Y(:,1);

Reply With Quote
  #4 (permalink)
Posts: 7 since Apr 2010
Thanks: 10 given, 5 received

Fully automated ARIMA code. Does the following:
1) Checks for stationarity and if nonstationary, makes the difference adjustments for Ith order accordingly.
2) Checks for White Noise on the stationary series using Ljung Box
3) If not a White Noise, AR-MA combination is run and the one with the best Bayesian Information Criterion is selected.

With a slight tweak in garchfit code, explanatory variables can be included as well.

Sections to customize:
%Loading Data%

Requires 'Econometrics Toolbox'

%Loading Data%
load Nifty.mat;

Input = Close;
WNLagPeriod = 10; %White Noise Lag Period%
MaxI = 5;        %Maximum integrand period%
MaxAR = 5;       %Maximum AR lookback%
MaxMA = 5;       %Maximum MA lookback%

%Checking for I(n) process%
VarianceMatrix = zeros(MaxI,1);
for I = 1: MaxI
    VarianceMatrix(I,1) = var(diff(Input,I));

IMatrix = find(ismember(VarianceMatrix, min(VarianceMatrix))==1);

if var(Input) < min(VarianceMatrix)
    I = 0;
    I = IMatrix;

%Making Data Stationary%
if I > 0
    StationaryInput = diff(Input,I);
    StationaryInput = Input;

[row1,~] = size(StationaryInput);

%Testing for White-Noise%
[LBTestH,~,~,~] = lbqtest(StationaryInput, WNLagPeriod,[],[]);

clear LBTestValue LBTeststat LBTestCriticalValue WNLagPeriod

%Start Iterations%
if LBTestH == 0
    disp(['The process is white noise at I = ', num2str(I)]);
    %Selecting AR & MA Process based on AIC%
    Z = zeros(MaxAR + 1,MaxMA+1);
    for MA = 0: MaxMA
        for AR = 0: MaxAR
            i = AR + 1;
            j = MA + 1;
            spec = garchset('R', AR, 'M', MA, 'P', 0, 'Q', 0);
            [Coeff,~,LLF,~,~,~] = garchfit(spec,StationaryInput);
            Parameters = garchcount(Coeff);
            [~,BIC] = aicbic(LLF,Parameters,row1);
            Z(i,j) = BIC;

clear AR MA spec Coeff LLF AIC CSize i j row1

[row,column] = find(ismember(Z, min(min(Z),[],2)));
ARp = row - 1;
MAq = column - 1;
spec = garchset('R',ARp,'M',MAq,'P',0,'Q',0);
[FinalCoeff,FinalErrors,~,FinalInnovations,~,FinalSummary] = garchfit(spec,StationaryInput);
garchdisp(FinalCoeff, FinalErrors)
RSquared = 1 - corr(StationaryInput,FinalInnovations)

clear row column  Input RowNumber StationaryInput Parameters;
clear LBTestH VarianceMatrix IMatrix MaxAR MaxMA MaxI AIC AR MA;

Reply With Quote


futures io > > > > Help: Code for Automating ARMA Identification in Matlab

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

futures io is celebrating 10-years w/ over $18,000 in prizes!

Right now

$250 Amazon Gift Cards with our "Thanks Contest" challenge!

Right now

Similar Threads
Thread Thread Starter Forum Replies Last Post
matlab c# wh The Elite Circle 3 June 14th, 2011 09:22 PM
Rithmic and matlab tradersheldon Matlab, R project and Python 1 January 28th, 2011 01:16 PM
Price Bar Counts, Coding and Identification wh The Elite Circle 2 August 11th, 2010 12:36 PM
Working on automating The Holy Grail & Sharky's method BigDog NinjaTrader Programming 15 January 21st, 2010 12:54 PM

All times are GMT -4. The time now is 02:05 AM. (this page content is cached, log in for real-time version)

Copyright © 2020 by futures io, s.a., Av Ricardo J. Alfaro, Century Tower, Panama, +507 833-9432,
All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts