m = 1:length(newMean)
    <span class="keyword">if</span> ~isnan(newMean(nm))
        simLTM(nm) = newMean(nm);
    <span class="keyword">end</span>
<span class="keyword">end</span>
</pre><h2>5. Set the constant vector of VAR(p) model such that process is stationary around long-term mean (or alternate value)<a name="7"></a></h2><pre class="codeinput">s.B=[simLTM-repmat(simLTM,1,nlag)*s.B_; s.B_]';
</pre><h2>6. Compute VAR error and significance measures<a name="8"></a></h2><pre class="codeinput">N=length(Y)