Creating a fan chart in R from an Arima model

Hi, I have come across this blogpost on creating a fanchart for forecasts in R (https://bankunderground.co.uk/2019/11/19/build-your-own-fancharts-in-r/). I'm interested in doing something similar, however I would like to do one for an ARIMA model as opposed to the VAR that the authors did. I know how to create an ARIMA and point forecasts, however I'm looking for advice on the best way to simulate future values and plot it as a fan chart in a similar way to the plot in the link.

structure(list(Date = structure(c(12478, 12570, 12662, 12753, 
12843, 12935, 13027, 13118, 13208, 13300, 13392, 13483, 13573, 
13665, 13757, 13848, 13939, 14031, 14123, 14214, 14304, 14396, 
14488, 14579, 14669, 14761, 14853, 14944, 15034, 15126, 15218, 
15309, 15400, 15492, 15584, 15675, 15765, 15857, 15949, 16040, 
16130, 16222, 16314, 16405, 16495, 16587, 16679, 16770, 16861, 
16953, 17045, 17136, 17226, 17318, 17410, 17501, 17591, 17683, 
17775, 17866), class = "Date"), Index = c(99.9820253708305, 100.194245830908, 
100.464139353185, 100.509664967831, 100.0275008635, 100.372695892486, 
100.468066533557, 100.576244163805, 100.623717628381, 100.780442246863, 
100.65264776914, 100.69366042058, 100.909079987983, 101.018619794549, 
100.959015810121, 101.04835942569, 100.681089538573, 100.663660573108, 
100.522268447626, 100.22783149065, 99.4643787364223, 99.4331456182866, 
99.5626187912313, 100.039081681562, 100.418818090577, 100.4652077117, 
100.544938523663, 100.643407515773, 100.44741458842, 100.502455228311, 
100.695097023592, 100.716907300461, 100.555884307168, 100.503742436422, 
100.432566888692, 100.553320081068, 100.32442656222, 100.456727368091, 
100.350509427919, 100.677833560057, 100.362403841025, 100.827860652847, 
100.499496900756, 100.418652455482, 100.234221207155, 100.25208930362, 
100.159571677823, 100.229735300634, 100.369332695161, 100.169972399177, 
100.17207717391, 100.35130514679, 99.9317959389533, 99.8704136030018, 
100.052802025981, 100.176345514426, 100.355049154025, 100.544145324359, 
100.549886876118, 100.5559420697)), row.names = c(NA, -60L), class = c("tbl_df", 
"tbl", "data.frame"))

from this dataframe, I have created an ARIMA and simulated future values

library(tbl2xts)
library(stats)
library(forecast)

data <- data %>% mutate(Index=log(Index)) %>% 
  tbl_xts()

model <- auto.arima(data)

#Simulate values from Arima Model

simulation <- matrix(NA, nrow=1000, ncol=8)
for(i in 1:1000)
  simulation[i,] <- simulate(model, nsim=8)

Is it possible to plot these simulated values as a fanchart similar to the charts in the link I've attached?

There is an example here: https://stackoverflow.com/a/63488700/144157

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.