I am currently working on a sample data that requires me to perform time series forecasting in R on a given set of data.So i need to forecast for daily basis. I am getting the following error message.
Error in
-.default
(x, trend) : non-numeric argument to binary operator
My data format
Items Regions vDate QTY
Tractor TT35 4WD Tiruchengode 2016-01-01 2
Tractor TT35 4WD Tiruchengode 2016-01-02 7
Tractor TT35 4WD Tiruchengode 2016-01-03 6
Tractor TT35 4WD Tiruchengode 2016-01-04 0
Tractor TT35 4WD Tiruchengode 2016-01-05 6
Tractor TT35 4WD Tiruchengode 2016-01-06 6
Tractor TT35 4WD Tiruchengode 2016-01-07 1
Tractor TT35 4WD Tiruchengode 2016-01-08 6
Tractor TT35 4WD Tiruchengode 2016-01-09 0
Tractor TT35 4WD Tiruchengode 2016-01-10 4
Tractor TT35 4WD Tiruchengode 2016-01-11 4
Tractor TT35 4WD Tiruchengode 2016-01-12 0
Tractor TT35 4WD Tiruchengode 2016-01-13 6
Tractor TT35 4WD Tiruchengode 2016-01-14 7
Tractor TT35 4WD Tiruchengode 2016-01-15 3
In items column i have three types , in regions column there are 18 regions , for each region i have three items and for each item i have two years of data (2016-01-01 to 2017-01-31), i need to forecast the QTY column for the next year(2018-01-31)
I am using the below code
ts_temp = ts(dt_ts[Regions==i & Item==j,]$Data,frequency = 365,start =
c(2016,1,1))
# plot(ts_temp)
#tsss<-decompose(ts_temp)
#plot(tsss)
model_hw = HoltWinters(ts_temp)
When i run model_hw iam getting the above error.
Any suggestions please,
Thanks in Advance
The following script gave me no problems:
library(readr)
dt_ts <- read_csv("~/test.csv")
attach(dt_ts)
i = 'Tiruchengode'
j = 'Tractor TT35 4WD'
ts_temp = ts(dt_ts[Regions==i & Items==j,]$QTY,frequency = 365,start = c(2016,1,1))
model_hw = HoltWinters(ts_temp)
That error message means that HoltWinters()
is trying to perform a binary operation, like 2+2, with something that isn't a number. Try validating your data to make sure QTY contains only numbers:
class(dt_ts[Regions==i & Items==j,]$QTY)
should return:
[1] "integer"