Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Your example can't be replicated, but this is a pretty simple problem in general. The first step is to write a function doing whatever you want to each timeseries. I'm trusting that you want to do everything in your example above, so a function like this should do the trick:</p> <pre><code>runArima &lt;- function(ts){ Higher.R2.18. &lt;- auto.arima(ts,test="adf") p &lt;- plot(forecast(Higher.R2.18.,h=22)) pred &lt;- forecast(Higher.R2.18.,h=22) correlation6 &lt;- cor(fitted(Higher.R2.18.),ts) return(list(arima=Higher.R2.18.,plot=p,forecast=pred,cor=correlation6)) } </code></pre> <p>Then you just need to apply that function to your list of time series. The more "R" way to do it is with an apply statement:</p> <pre><code>arima.list &lt;- lapply(&lt;list of timeseries&gt;,runArima) </code></pre> <p>But you can use a loop if you prefer:</p> <pre><code>arima.list &lt;- vector(length(&lt;list of timeseries&gt;),"list") i &lt;- 1 for(ts in &lt;list of timeseries&gt;){ arima.list[[i]] &lt;- runArima(ts) i &lt;- i + 1 } </code></pre> <p>Here is an example with some trivial data:</p> <pre><code>&gt; library(forecast) &gt; #make trivial list of time series since i don't have one &gt; ts.list &lt;- lapply(1:5,function(x) WWWusage) &gt; #run your function across list of time series &gt; arima.list &lt;- lapply(ts.list,runArima) &gt; #look at some results &gt; arima.list[[1]]$arima Series: ts ARIMA(2,2,0) Coefficients: ar1 ar2 0.2579 -0.4407 s.e. 0.0915 0.0906 sigma^2 estimated as 10.13: log likelihood=-252.73 AIC=511.46 AICc=511.72 BIC=519.22 &gt; arima.list[[1]]$cor [1] 0.9972077 </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload