title: Matlab, Econometrics toolbox - Simulate ARIMA with deterministic time-varying variance
body: <p><strong>DISCLAIMER:</strong> This question is only for those who have access to the econometrics toolbox in Matlab. </p>
  
  <p><strong>The Situation:</strong> I would like to use Matlab to simulate <code>N</code> observations from an ARIMA(p, d, q) model using the econometrics toolbox. What's the difficulty? I would like the innovations to be simulated with deterministic, time-varying variance.</p>
  
  <p><strong>Question 1)</strong> Can I do this using the in-built matlab <code>simulate</code> function <em>without altering it myself</em>? As near as I can tell, this is not possible. From my reading of the docs, the innovations can either be specified to have a constant variance (ie same variance for each innovation), or be specified to be stochastically time-varying (eg a GARCH model), but they cannot be deterministically time-varying, where I, the user, choose their values (except in the trivial constant case).</p>
  
  <p><strong>Question 2)</strong> If the answer to <strong>question 1</strong> is "No", then does anyone see any reason why I can't edit the <code>simulate</code> function from the econometrics toolbox as follows:
  a) Alter the preamble such that the function won't throw an error if the <code>Variance</code> field in the input <code>model</code> is set to a numeric vector instead of a numeric scalar.
  b) Alter line 310 of <code>simulate</code> from:</p>
  
  <pre><code>E(:,(maxPQ + 1:end)) = Z * sqrt(variance);
  </code></pre>
  
  <p>to</p>
  
  <pre><code>E(:,(maxPQ + 1:end)) = (ones(NumPath, 1) * sqrt(variance)) .* Z;
  </code></pre>
  
  <p>where <code>NumPath</code> is the number of paths to be simulated, and it can be assumed that I've included an error trap to ensure that the (input) deterministic variance path stored in <code>variance</code> is of the right length (ie equal to the number of observations to be simulated per path).</p>
  
  <p>Any help would be most appreciated. Apologies if the question seems basic, I just haven't ever edited one of Mathwork's own functions before and didn't want to do something foolish.</p>
  
  <p><strong>UPDATE (2012-10-18):</strong> I'm confident that the code edit I've suggested above is valid, and I'm mostly confident that it won't break anything else. However it turns out that implementing the solution is not trivial due to file permissions. I'm currently talking with Mathworks about the best way to achieve my goal. I'll post the results here once I have them.</p>