0

I have used a time series data for forecast with the exponential smoothing method. But I got the following errors, could anyone pls help me figure where the problem is?

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

RMP<-{Date<-(2018-02-01,2018-03-01,2018-04-01,2018-05-01,2018-06-1...2019-08-01), Price<-(157,158,159,157.5,160,152........166)}

In total I have 19 dates continuesly with the price values from 2018-2-1 to 2019-8-1. I tried using the HoltWinters function to make the forecast but I got the error: Error in decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal) : time series has no or less than 2 periods. Here is my code:

rmprice=RMP$Price
rmpts <- ts(rmprice, frequency=12, start=c(2018,2))
logrmp<- log(rmpts)
#plot.ts(logrmp) 
library("TTR")

rmptsfc <- HoltWinters(logrmp)
rmptsfc2 <-forecast:::forecast.HoltWinters(rmptsfc, h)

It comes with the error: Error in decompose(ts(x[1L:wind], start = start(x), frequency = f), seasonal) : time series has no or less than 2 periods. Here is my code:

I tried to use

rmptsfc <- HoltWinters(logrmp,beta = FALSE, gamma = FALSE)

Then the error is gone, but all the forecast values are a flat line with the same values. That's not what I want.

Could anyone pls kindly give advice? Thanks a lot!

jogo
  • 12,469
  • 11
  • 37
  • 42
Cherry
  • 73
  • 6

0 Answers0