Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Multiple time series in a long format tsibble

$
0
0

I want to run time series models to forecast one step ahead using fable package. As far I understand, I need to have my data in tsibble format. Here is what I am trying to do,

  • Generate three ids
  • Time stamps for those three ids
  • Three random series
  • Join it all as a tsibble
  • One month ahead forecast

So I want to make a tsibble first. To do that I am trying to create by using the following lines,

ts <- tsibble(
  ids = c(rep(43, 20), rep(33, 20), rep(11, 20)),
  timest = rep(yearmonth("2010 Jan") + 0:19, each = 3),
  data = rnorm(60, mean = 10, sd = 5),
  key = ids
)

Using this tsibble I want to run the following models,

fit <- ts %>%
  model(
    arima = ARIMA(data)
  )
fit

fc <- fit %>%
  forecast(h = "1 month")
fc

However, I am having problem in creating tsibble. I know that I cannot have duplicates but pointing key = ids should solve the problem. Anybody can help me to find the mistake I am doing?


Viewing all articles
Browse latest Browse all 201839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>