title: Error in rep(1, n.ahead) : invalid 'times' argument in R
body: <p>I'm working on dataset to forecast with ARIMA, and I'm so close to the last step but I'm getting error and couldn't find reference to figure out what I'm missing. </p>
  
  <p>I keep getting error message when I do the following command:</p>
  
  <pre><code>ForcastData&lt;-forecast(fitModel,testData)
  
  Error in rep(1, n.ahead) : invalid 'times' argument
  </code></pre>
  
  <p>I'll give brief view on the work I did where I have changed my dataset from data frame to Time series and did all tests to check volatility, and Detect if data stationary or not.<br>
  Then I got the DataAsStationary as good clean data to apply ARIMA, but since I wanna train the model on train data and test it on the other part of the data, I splitted dataset into training 70% and testing 30%:  </p>
  
  <pre><code>ind &lt;-sample(2, nrow(DataAsStationary), replace = TRUE, prob = c(0.7,0.3))
  traingData&lt;- DataStationary1[ind==1,]
  testData&lt;- DataStationary1[ind==2,]
  </code></pre>
  
  <p>I used Automatic Selection Algorithm and found that Arima(2,0,3) is the best.</p>
  
  <pre><code>autoARIMAFastTrain1&lt;- auto.arima(traingData, trace= TRUE, ic ="aicc", approximation = FALSE, stepwise = FALSE)
  </code></pre>
  
  <p>I have to mentioned that I did check the if residuals are Uncorrelated (White Noise) and deal with it.</p>
  
  <pre><code>library(tseries)
  library(astsa)
  library(forecast)
  </code></pre>
  
  <p>After that I used the training dataset to fit the model:</p>
  
  <pre><code>fitModel &lt;- Arima(traingData, order=c(2,0,3))
  fitted(fitModel)
  
  ForcastData&lt;-forecast(fitModel,testData)
  output &lt;- cbind(testData, ForcastData)
  accuracy(testData, ForcastData) 
  plot(outp)
  </code></pre>
  
  <p>Couldn't find any resource about the error:  </p>
  
  <blockquote>
    <p>Error in rep(1, n.ahead) : invalid 'times' argument  </p>
  </blockquote>
  
  <p>Any suggestions!! Really</p>
  
  <p>I tried     </p>
  
  <pre><code>ForcastData&lt;-forecast.Arima(fitModel,testData)
  </code></pre>
  
  <p>but I get error that  </p>
  
  <blockquote>
    <p>forecast.Arima not found !  </p>
  </blockquote>
  
  <p>Any idea why I get the error?</p>