title: ARIMA time series forecasting not working in R
body: <p>I'm trying to forecasting on a time series that looks like this (this is testing data)</p>
  
  <pre><code>[1] 1 1 1 1 4 1 3 4 5 6 5 1 1 1 1 1 5 3 4 7 5 5 6 4 1 1 1 1 1 1 4 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 8 2
  </code></pre>
  
  <p>I get the data from a US state. Let's say Alabama like this</p>
  
  <pre><code>res &lt;- subset(d, states == 'Alabama', select = c(levels, weeks))
  </code></pre>
  
  <p>I then turn the levels data into a time series like this.</p>
  
  <pre><code>tsn = ts(res[[1]])
  </code></pre>
  
  <p>I then get the best arima model fit like this</p>
  
  <pre><code>aa &lt;- auto.arima(tsn)
  </code></pre>
  
  <p>For which the result is this</p>
  
  <pre><code>Series: tsn 
  ARIMA(1,0,0) with non-zero mean 
  
  Coefficients:
           ar1  intercept
        0.4722     2.2833
  s.e.  0.1252     0.4644
  
  sigma^2 estimated as 2.989:  log likelihood=-94.51
  AIC=195.03   AICc=195.57   BIC=200.64
  </code></pre>
  
  <p>I then try to use the forecast function like this</p>
  
  <pre><code>forecast(aa)
  </code></pre>
  
  <p>And this is when I get this error</p>
  
  <pre><code>Error in forecast(aa) : unused argument (aa)
  </code></pre>
  
  <p>Any idea how to make the forecast work?</p>
  
  <p><strong>Edit to add code</strong></p>
  
  <p>This is how the data looks like</p>
  
  <pre><code>st      URL                         WEBSITE                 al      aln     wk          WEEKSEASON
  Alabama http://adph.org/influenza/  Influenza Surveillance  Level 1 Minimal Oct-04-2008 40  2008-09
  Alabama http://adph.org/influenza/  Influenza Surveillance  Level 1 Minimal Oct-11-2008 41  2008-09
  Alaska  http://adph.org/influenza/  Influenza Surveillance  Level 1 Minimal Oct-18-2008 42  2008-09
  Alaska  http://adph.org/influenza/  Influenza Surveillance  Level 1 Minimal Oct-25-2008 43  2008-09
  </code></pre>
  
  <p>This is how the code looks like</p>
  
  <pre><code>library(forecast)
  library(tseries)
  
  #Extracts relevant data from the csv file
  extract_data&lt;-function(){
  
    #open the file. NAME SHOULD BE CHANGED
    sd &lt;- read.csv(file="sdr.csv",head=TRUE,sep=",")
  
    #Extracts the data from the ACTIVITY LEVEL column. Notice that the name of the column was changed on the file
    #to 'al' to make the reference easier
    lv_list &lt;- sd$al
    #Gets only the number from each value getting rid of the word "Level"
    lvs &lt;- sapply(strsplit(as.character(lv_list), " "), function(x) x[2])
  
    #Gets the ACTIVITY LEVEL NAME. Column name was changed to 'aln' on the file
    lvn_list &lt;- sd$aln
  
    #Gets the state. Column name was changed to 'st' on the file
    st_list &lt;- sd$st
  
    #Gets the week. Column name was changed to 'wk' on the file
    wlist &lt;- sd$wk
    #Divides the weeks data in month, day, year
    wks &lt;- sapply(strsplit(as.character(wlist), "-"), function(x) c(x[1], x[2], x[3]))
  
    #Creates a data frame with the selected results. You can choose which data is needed.
    result&lt;-data.frame("states"=st_list,"levels"=lvs,"lvlnames"=lvn_list,"weeks"=wlist)  
  
    return(result)
  
  }
  
  forecast&lt;-function(){
  
    d=extract_data()
  
    #Get data from each state
    res &lt;- subset(d, states == 'Alabama', select = c(levels, weeks))
  
    #turn data into a time series
    tsn = ts(res[[1]])
  
    #Plot forecast data with ARIMA models (use differenciated data if needed)
    aa &lt;- auto.arima(tsn)
    forecast(aa)
  
    return(0) #return results
  }
  </code></pre>