0

I'm trying to apply tbats model on timeseries data. This dataframe contains values in the range of 0 to 1. Before applying model , I replaced all the 0 values with NA's (because I wanted to take log of the dataset and the log of 0 values will give -inf) and and then took the log of all the values to prepare dataframe for TBATS.

After all the changes as mentioned above, dataframe looks like below:

     y_ds0           timestamp
1    -2.9957323 2017-08-07 01:01:00
2    -3.2188758 2017-08-07 01:01:10
3    -3.2188758 2017-08-07 01:01:20
4    -3.5065579 2017-08-07 01:01:30
5    -3.5065579 2017-08-07 01:01:40
6    -3.9120230 2017-08-07 01:01:50
7    -3.9120230 2017-08-07 01:02:00
8    -4.6051702 2017-08-07 01:02:10
9    -4.6051702 2017-08-07 01:02:20
10   -4.6051702 2017-08-07 01:02:30
11   -4.6051702 2017-08-07 01:02:40
12   -4.6051702 2017-08-07 01:02:50
13           NA 2017-08-07 01:03:00
14           NA 2017-08-07 01:03:10
15           NA 2017-08-07 01:03:20
16           NA 2017-08-07 01:03:30
17           NA 2017-08-07 01:03:40
18           NA 2017-08-07 01:03:50
19           NA 2017-08-07 01:04:00
20           NA 2017-08-07 01:04:10
21           NA 2017-08-07 01:04:20
22           NA 2017-08-07 01:04:30
23           NA 2017-08-07 01:04:40
24           NA 2017-08-07 01:04:50
25           NA 2017-08-07 01:05:00
26   -2.5257286 2017-08-07 01:05:10
27   -2.6592600 2017-08-07 01:05:20
28   -2.8134107 2017-08-07 01:05:30
29   -2.9957323 2017-08-07 01:05:40
30   -3.2188758 2017-08-07 01:05:50
31   -3.5065579 2017-08-07 01:06:00
32   -3.5065579 2017-08-07 01:06:10
33   -3.9120230 2017-08-07 01:06:20
34   -3.9120230 2017-08-07 01:06:30
35   -3.9120230 2017-08-07 01:06:40
36   -4.6051702 2017-08-07 01:06:50
37   -4.6051702 2017-08-07 01:07:00

It has 1000 more rows in the data.

On the above dataframe, I applied TBATS model using below code:

tk_ts_dataframe <- tk_ts(ts_df ,
            start = 1,
            freq = 6,
            silent = TRUE)

fit <- tbats(tk_ts_dataframe)

forecast <- forecast(fit, h = 1)

I'm getting error like below:

Error in attributes(best.model$errors) <- attributes(origy) : dims [product 1435] do not match the length of object [236]

Please help me in resolving this. auto.arima() works completely fine in this dataset.

i.n.n.m
  • 2,936
  • 7
  • 27
  • 51
Ashag
  • 837
  • 2
  • 15
  • 24
  • Possibly the missing values which are handled by auto.arima but not by tbats. – Rob Hyndman Aug 07 '17 at 05:42
  • @RobHyndman , thanks for the response. What should be the ideal way to deal with this. As of now, what I did is, instead of replacing 0 with NA's, i replaced it with 0.001 and the model worked. – Ashag Aug 07 '17 at 06:06
  • 1
    Try using the imputeTS package. See https://cran.r-project.org/web/packages/imputeTS/vignettes/imputeTS-Time-Series-Missing-Value-Imputation-in-R.pdf for details. – Rob Hyndman Aug 07 '17 at 07:21

0 Answers0