Time series less than 2 periods

Hi all,

I am working on a time series data. The data has daily data for 2 years i.e Dec 2009 to Dec 2011. Also, it has some dates missing from it(approx 143). How can I do the Time series prediction. Because when I am trying to do the time series decomposition, it says- Time series has no or less than 2 periods.

How can I do the time series prediction?

The recommended forecast method for daily data from the Hyndman textbooks is tbats. For a daily time series, you'd probably want to include both weekly (period 7) and annual (period 365.25) seasonality. The forecast package includes both a data type for time series with multiple periods of seasonality msts and the tbats forecast method.

If you wanted a simpler approach, you could just ditch the annual seasonality and include the weekly with ts and ets. If your data is very sparse or noisy, this might be better.

#> Registered S3 method overwritten by 'quantmod':
#>   method            from
#>   as.zoo.data.frame zoo

# define some time series data
d <- tibble(
  x    = 1:(365*2), 
  y    = 5 + sin(x*2*pi/7) + 0.5*sin(x*2*pi/365.25) + runif(length(x)),
  # multiple period ts
  ser2 = msts(y, seasonal.periods = c(7, 365.25), start = 2019),
  # single period ts
  ser1 = ts(y, frequency = 7)

# plot the time series
# not sure why the annual seasonality doesn't appear in the PACF at lag 365...
ggtsdisplay(d$ser2, lag.max = 371)
#> Warning in periods * seq(-20:20): longer object length is not a multiple of
#> shorter object length

#> Warning in periods * seq(-20:20): longer object length is not a multiple of
#> shorter object length

# fit a tbats model and make a forecast
model <- tbats(d$ser2)
forec <- forecast(model, h = 60) 
autoplot(forec) + coord_cartesian(xlim = c(2020.8, NA))

# simpler approach is to ignore annual seasonality just fit ets with weekly seasonality
ets(d$ser1) %>% forecast(h = 60) %>% autoplot() + coord_cartesian(xlim = c(100, NA))

Created on 2021-05-31 by the reprex package (v1.0.0)

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.