Y_(:,idx);     %exogenous variable has AR(p) process
end


%% 4. Set an alternate value (instead of long-term mean) for variables to center around, if applicable
simLTM=LTM;
for nm = 1:length(newMean)
    if ~isnan(newMean(nm))
        simLTM(nm) = newMean(nm);
    end
end


%% 5. Set the constant vector of VAR(p) model such that process is stationary around long-term mean (or alternate value)
s.B=[simLTM-repmat(simLTM,1,nlag)*s.B_; s.B_]'; 


%% 6. Compute VAR error and significance measures
N=length(Y);  