5
$\begingroup$

I'm working actually on the modeling of times series with auto.arima from package forecasts. But i enconter some problems regarding the extraction of values Lo 80, Hi 80, Lo 95, Hi 95 singularly. I have retrieved data to excel with function csv but it 's too long and there are some risks to loose data. I have retrieved only the mean or the point forecast with the function AA11a[["mean"]] as you can see on my codes in R

a<-ts(AA,start=1921,end=2009,frequency=1)
fit11a<-auto.arima(b,allowdrift=TRUE)
AA11a<-forecast(fit11a,50)
plot(AA11a)
plot(AA11a[["mean"]])

I want to ask how can i extract the Lo 80, Hi 80, Lo 95, Hi 95 singularly? I have tried this code AA11a$fcst$AA[,1]

but it doesn't work and tell me : Null

The other alternative is to send the output AA11a to excel and find singularly variables but before exploring that path i will ask whether somebody has an idea on how to extract different values i have cited above with codes in R. Thanks

$\endgroup$

closed as off-topic by mdewey, whuber May 24 '17 at 13:17

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – mdewey, whuber
If this question can be reworded to fit the rules in the help center, please edit the question.

6
$\begingroup$

You didn't provide your data. So I am guessing what you are looking for: I think you want to get something like this:

> library(forecast)
> fit=Arima(WWWusage,c(3,1,0))
> AA11a<-forecast(fit)
> AA11a$lower
               80%      95%
     [1,] 215.7393 213.6634
     [2,] 209.9265 205.0016
     [3,] 203.8380 196.1947
     [4,] 198.3212 188.2489
     [5,] 193.2807 180.8498
     [6,] 188.3324 173.4858
     [7,] 183.3651 166.0860
     [8,] 178.5027 158.8474
     [9,] 173.8431 151.8879
    [10,] 169.3780 145.1874
    > AA11a$upper
           80%      95%
 [1,] 223.5823 225.6582
 [2,] 228.5332 233.4581
 [3,] 232.7151 240.3585
 [4,] 236.3756 246.4479
 [5,] 240.2458 252.6768
 [6,] 244.4246 259.2713
 [7,] 248.6473 265.9264
 [
 [9,] 256.7919 278.7471
[10,] 260.7719 284.9625
> AA11a$upper[1,2]
         95% 
    225.6582 
> AA11a$lower[,2]
 [1] 213.6634 205.0016 196.1947 188.2489 180.8498 173.4858 166.0860 158.8474
 [9] 151.8879 145.1874
> 
$\endgroup$
  • $\begingroup$ Thanks so much. Codes you provide me are working at 100%. Thanks $\endgroup$ – ntamjo achille Jan 18 '14 at 1:08
3
$\begingroup$

To extract the mean of the prediction interval as a numeric vector use:

> as.numeric(AA11a$mean)
 [1] 219.6608 219.2299 218.2766 217.3484 216.7633 216.3785 216.0062 215.6326 215.3175
[10] 215.0749

The mean itself is a tsclass

> class(AA11a$mean)
[1] "ts"
$\endgroup$
  • $\begingroup$ Thanks, lost half na hour on that! Other question, I see the residuals, and the timeseries actuals (x) are there, but is there a column with the historical predictions? or do I have to create a new column x+residual if I want to plot both? Thanks $\endgroup$ – Diego Duarte Nov 2 '17 at 23:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.