title: Out of Sample forecast with auto.arima() and xreg
body: <p>I'm working on a forecasting model, where I have monthly data from 2014 to current month (March 2018).</p>
  
  <p>Part of my data are a column for billings and a column for quote amounts, e.g.
  (Apologies for the formatting)</p>
  
  <p>Year - Quarter - Month -   BILLINGS - QUOTES<br/>
  2014- 2014Q1--  201401-  100-------------500<br/>
  2014-  2014Q1--  201402-  150-------------600<br/>
  2014-  2014Q1--  201403-  200-------------700<br/></p>
  
  <p>I'm using this to predict monthly sales, and attempting to use xreg with the number of quotes monthly.</p>
  
  <p>I reviewed the article below, but am missing something to accomplish what I'm trying to do:
  <a href="https://stackoverflow.com/questions/34249477/arima-forecasting-with-auto-arima-and-xreg">ARIMA forecasting with auto.Arima() and xreg</a></p>
  
  <p>Question: Can somebody show an example of forecasting OUT OF SAMPLE using xreg?  I understand that in order to accomplish this, you need to forecast your xreg variables out of sample, but I cannot figure out how to pass those future values in.</p>
  
  <p>I tried using something like futurevalues$mean after predicting the values, but this did not work.</p>
  
  <p>Here is my code:</p>
  
  <pre><code>sales = read.csv('sales.csv')
  
  # Below, I'm creating a training set for the models through 
  #  December 2017 (48 months).
  train = sales[sales$TRX_MON&lt;=201712,]
  
  # I will also create a test set for our data from January 2018 (3 months)
  test = sales[sales$TRX_MON&gt;201712,]
  
  dtstr2 &lt;- ts(train2, start=2014, frequency=12)
  dtste2 &lt;- ts(test2, start=2018, frequency=12)
  
  fit2 &lt;- auto.arima(dtstr2[,"BILLINGS"], xreg=dtstr2[,"QUOTES"])
  fcast2 &lt;- forecast(fit2, xreg=dtste2[,"QUOTES"], h=24)
  fcast2
  </code></pre>
  
  <p>The code above works, but only gives mea 3 month forecast, e.g.</p>
  
  <pre><code>                  Point Forecast    Lo 80    Hi 80    Lo 95    Hi 95
  Jan 2018          70                60       100      50       130
  Feb 2018          80                70       110      60       140
  Mar 2018          90                80       120      70       150
  </code></pre>
  
  <p>I have scoured as many blogs and topics I could find seeking an example of using auto.arima with an out of sample forecast of an xreg variable, and cannot find any that have done this.</p>
  
  <p>Can anybody help?</p>
  
  <p>Thank you much.</p>