=length(lag);
  lag=max(lagStep);
end
if size(Y,1)<size(Y,2)
  Y=Y';
end

%If no long-term mean vector set for LTM, use mean of historical data 
if nargin < 4    
  LTM = mean(Y); 
elseif size(LTM,1)>size(LTM,2)
  LTM=LTM';
end

%If no exogenous variables set for exo, that variable is NULL
if nargin < 5   
  exo = [];
end

%If no alternate mean vector set for newMean, that variable is NULL
if nargin < 6
    newMean = [];   
end


%% 2. Estimate coefficients of VAR(p) model (excluding the constants), by regr