I have simple monthly dataset and simply trying this code:
`df2.holtwinters <- subset(df, account_id==loopitem)
x.holtwinters <- ts(df2.holtwinters$amount_usd, start = c(2015,1), end = c(2019,5), frequency = 12)
arima1.holtwinters <- HoltWinters(x.holtwinters)
forecast1.holtwinters <- predict(arima1.holtwinters, n.ahead=1*1)
The dataset look like this:
` id <date> <dbl>
1 123 2015-01-01 -390
2 123 2015-02-01 944
3 999 2015-01-01 672
It is giving following erros:
`In HoltWinters(x.holtwinters) :
optimization difficulties: ERROR: ABNORMAL_TERMINATION_IN_LNSRCH
Since I cannot see which data you are using, it is not easy to say what went wrong, but here is an example code which might be helpful. Let's get retail data from Rob Hyndman's website
remove date column and create a mts classed data
plot the first time series (first column)
fit Holt Winters to first time series in the data
use predict function to get forecast as you did
Or you can use forecast function to get a forecast output which is nice.
using AirPassengers data if for some reasons you could not get retail data
or you can use forecast function to get a forecast output
forecasting loop for many time series
I would recommend to take look into
fable
package.