Search code examples
rtime-seriespredictionholtwinters

Forecasting Daily Data using HoltWinters


First of all I have already consulted this article and this but couldn't get it to work.

I have daily data starting from 28-03-2015 till 27-02-2017. My TS object looks like this:

bvg11_prod_ts <- ts(bvg11_data$MA_PROD, freq=365, start=c(2015, 87), end=c(2017, 58))

the below graph shows the daily values:

autoplot(bvg11_prod_ts)

enter image description here

I have also tried creating the daily ts object by:

bvg11_prod_ts <- ts(bvg11_data$MA_PROD, freq=7, start=c(2015, 3), end=c(2017, 02))
autoplot(bvg11_prod_ts)

which results in this plot: enter image description here

As you can see both graphs are completely different, however, the first one is more accurate!

Now when i try to use the bvg11_prodsTSHoltWinter <- HoltWinters(bvg11_prod_ts) It gives error:

Error in decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal) : time series has no or less than 2 periods

What is wrong?


Solution

  • The error message is pretty clear: with a frequency of 365 you'll need at least 2*365 = 730 data points.

    x_err = ts(runif(729), freq = 365)
    # this gives an error
    fit = HoltWinters(x_err)
    
    # this will work
    x = ts(runif(730), freq = 365)
    fit = HoltWinters(x)