title: How to properly set start/end params of statsmodels.tsa.ar_model.AR.predict function
body: <p>I have a dataframe of project costs from an irregularly spaced time series that I would like to try to apply the <a href="http://www.statsmodels.org/stable/generated/statsmodels.tsa.ar_model.AR.html#statsmodels.tsa.ar_model.AR" rel="nofollow noreferrer"><code>statsmodel</code> AR model against</a>.</p>
  
  <p>This is a sample of the data in it's dataframe:</p>
  
  <pre><code>               cost
  date               
  2015-07-16    35.98
  2015-08-11    25.00
  2015-08-11    43.94
  2015-08-13    26.25
  2015-08-18    15.38
  2015-08-24    77.72
  2015-09-09    40.00
  2015-09-09    20.00
  2015-09-09    65.00
  2015-09-23    70.50
  2015-09-29    59.00
  2015-11-03    19.25
  2015-11-04    19.97
  2015-11-10    26.25
  2015-11-12    19.97
  2015-11-12    23.97
  2015-11-12    21.88
  2015-11-23    23.50
  2015-11-23    33.75
  2015-11-23    22.70
  2015-11-23    33.75
  2015-11-24    27.95
  2015-11-24    27.95
  2015-11-24    27.95
  ...
  2017-03-31    21.93
  2017-04-06    22.45
  2017-04-06    26.85
  2017-04-12    60.40
  2017-04-12    37.00
  2017-04-12    20.00
  2017-04-12    66.00
  2017-04-12    60.00
  2017-04-13    41.95
  2017-04-13    25.97
  2017-04-13    29.48
  2017-04-19    41.00
  2017-04-19    58.00
  2017-04-19    78.00
  2017-04-19    12.00
  2017-04-24    51.05
  2017-04-26    21.88
  2017-04-26    50.05
  2017-04-28    21.00
  2017-04-28    30.00
  </code></pre>
  
  <p>I am having a hard time understanding how to use <code>start</code> and <code>end</code> in the <code>predict</code> function. </p>
  
  <p>According to <a href="http://www.statsmodels.org/stable/generated/statsmodels.tsa.ar_model.AR.predict.html#statsmodels.tsa.ar_model.AR.predict" rel="nofollow noreferrer">the docs</a>:</p>
  
  <blockquote>
    <p>start : int, str, or datetime
    Zero-indexed observation number at which to start forecasting, ie., the first > forecast is start. Can also be a date string to parse or a datetime type.</p>
    
    <p>end : int, str, or datetime Zero-indexed observation number at which
    to end forecasting, ie., the first forecast is start. Can also be a
    date string to parse or a datetime type.</p>
  </blockquote>
  
  <p>I create a dataframe that has an empty daily time series, add my irregularly spaced time series data to it, and then try to apply the model.</p>
  
  <pre><code>data = pd.read_csv('data.csv', index_col=1, parse_dates=True)
  df = pd.DataFrame(index=pd.date_range(start=datetime(2015, 1, 1), end=datetime(2017, 12, 31), freq='d'))
  df = df.join(data)
  df.cost.interpolate(inplace=True)
  ar_model = sm.tsa.AR(df, missing='drop', freq='D')
  ar_res = ar_model.fit(maxlag=9, method='mle', disp=-1)
  pred = ar_res.predict(start='2016', end='2016')
  </code></pre>
  
  <p>The <code>predict</code> function results in an error of <code>pandas.tslib.OutOfBoundsDatetime: Out of bounds nanosecond timestamp: 605-12-31 00:00:00</code></p>
  
  <p>If I try to use a more specific date, I get the same type of error:</p>
  
  <pre><code>pred = ar_res.predict(start='2016-01-01', end='2016-06-01')    
  </code></pre>
  
  <p>If I try to use integers, I get a different error:</p>
  
  <pre><code>pred = ar_res.predict(start=0, end=len(data))
  Wrong number of items passed 202, placement implies 197
  </code></pre>
  
  <p>If I actually use a <code>datetime</code>, I get an error that reads <code>no rule for interpreting end</code>.</p>
  
  <p>I am hitting a wall so hard here I am thinking there must be something I am missing.</p>
  
  <p>Ultimately, I would like to use the model to get out-of-sample predictions (such as a prediction for next quarter).</p>