title: simulate and estimate ARMA model
body: <p>I'm trying to simulate an ARMA model and later simulate the AR and MA polynomial coefficients from the simulated time series.</p>
  <p>I found the following <a href="https://www.mathworks.com/help/econ/arima.html;jsessionid=0934c3853a8adeacc5e2f31e0da1#namevaluepairarguments" rel="nofollow noreferrer">ARIMA</a> function in MatLab that I hoped help me achieve my goal.
  Looking at the provided examples, I thought this would work:</p>
  <pre><code>AR_coef = {0.5, -0.1};
  MA_coef = {0.8, 0.5, 0.3};
  
  % simulate time series
  Mdl_in = arima('AR', AR_coef, ...
      'MA', MA_coef, ...
      'Constant', 0, ...
      'Variance', 1);
  y = simulate(Mdl_in,1,'NumPaths',10000);
  
  % estimate coefficients 
  Mdl_out = arima(numel(AR_coef), 0, numel(MA_coef));
  T = numel(y);
  idxpre = 1:Mdl_out.P;
  idxest = (Mdl_out.P + 1):T;
  EstMdl = estimate(Mdl_out,y(idxest)','Y0',y(idxpre)');
  </code></pre>
  <p>My hope was that EstMdl returns the <code>AR_coef</code> and <code>MA_coef</code> but it does not.
  Based on the random number generation, the estimated model parameter varies a lot.
  Can someone help me generate an example where I simulate an ARMA model and later estimate its coefficients?</p>
  <p>I'm also fine with using Python if it is easier.</p>