%'******************************************************************************
%'******************************************************************************
%' Program Name: HJC calculator
%'
%' This module is produced using Octave for determining the optimal lag order
%' of a VAR model based on the minimization of an information criterion
%' suggested by Hatemi-J (2003, 2008).
%'
%' This program is released under GNU General Public License, version 3.
%'
%' This program is free software: you can redistribute it and/or modify
%' it under the terms of the GNU General Public License as published by
%' the Free Software Foundation, either version 3 of the License, or
%' (at your option) any later version.
%'
%' This program is distributed in the hope that it will be useful,
%' but WITHOUT ANY WARRANTY; without even the implied warranty of
%' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
%' GNU General Public License for more details.
%'
%' You should have received a copy of the GNU General Public License
%' along with this program. If not, see .
%'
%' This software has been developed by Dr. Alan Mustafa under supervision of
%' Prof. Abdulnasser Hatemi-J (Hatemi-J; 2003, 2008).
%' Contacts:
%' - Prof. Abdulnasser Hatemi-J: AHatemi@uaeu.ac.ae
%' - Dr. Alan Mustafa: Alan.Mustafa@auk.edu.krd
%'
%' Date: February 2017
%'
%' © 2017 Prof. Abdulnasser Hatemi-J and Dr. Alan Mustafa
%'******************************************************************************
%'******************************************************************************
clear ; close all; clc %clearning out the memory and screen
filename = uigetfile({'*.*'},'File Selector'); % asking user for the file name
ys = dlmread(filename,',',1,0);
[T_, k] = size(ys); % T_ = data observation, and k = number of features
T = T_ -1;
while true
prompt = {'Enter number of lags (p): '};
dlgTitle = 'Value of Lags (p)';
num_lines = 1;
defaultValue = {'5'};
p_value = inputdlg(prompt,dlgTitle,num_lines,defaultValue);
p_value = str2num(p_value{1});
if ((p_value>1) & (p_value