Help needed in time series problem

r
time_series

#1

I have weekly booking date and qty for two years and I need to do analysis, if there is any pattern in the data or not. So, I tried using time series

for this requirement I approached with time series.

data as below

bookingdate bookingqty
2014-07-27        202
2014-08-03        564
2014-08-10        359
2014-08-17        638
2014-08-24        487
2014-08-31        491
2014-09-07        364
2014-09-14        762
2014-09-21        419
2014-09-28        642
2014-10-05        723
2014-10-12        579
2014-10-19       1803
2014-10-26        437
2014-11-02        587
2014-11-09        803
2014-11-16       1347
2014-11-23        600
2014-11-30        616
2014-12-07       2242
2014-12-14       1313
2014-12-21        264
2014-12-28        918
2015-01-04        420
2015-01-11        741
2015-01-18       2213
2015-01-25        379
2015-02-01        386
 2015-02-08        854
  2015-02-15       1235
   2015-02-22        726
  2015-03-01        774
   2015-03-08       1135
   2015-03-15       1127
  2015-03-22        466
  2015-03-29        987
   2015-04-05        665
   2015-04-12        997
   2015-04-19       2800
  2015-04-26        594
   2015-05-03        715
   2015-05-10       2009
   2015-05-17       1592
  2015-05-24        499
   2015-05-31       1906
   2015-06-07       1619
  2015-06-14       1277
   2015-06-21        683
   2015-06-28       2132
 2015-07-05       1195
  2015-07-12       1250
   2015-07-19       5001
   2015-07-26        320
   2015-08-02        577
   2015-08-09        825
   2015-08-16        885
   2015-08-23       1910
   2015-08-30       1072
   2015-09-06        615
   2015-09-13       1809
  2015-09-20       1243
   2015-09-27       1516
   2015-10-04        754
  2015-10-11        910
  2015-10-18       1766
   2015-10-25        599
   2015-11-01        536
   2015-11-08       1170
   2015-11-15       2060
  2015-11-22        719
   2015-11-29        706
  2015-12-06       1129
   2015-12-13       1807
   2015-12-20        949
   2015-12-27        653
   2016-01-03       1612
   2016-01-10       1058
   2016-01-17       2699
   2016-01-24        617
   2016-01-31        335
   2016-02-07        527
   2016-02-14        526
   2016-02-21       1729
 2016-02-28        512

   2016-03-06       1026

   2016-03-13        824

   2016-03-20       1144

   2016-03-27        711

   2016-04-03        743

   2016-04-10        847

   2016-04-17        833

   2016-04-24       4192

   2016-05-01        576

   2016-05-08        610

   2016-05-15        645

   2016-05-22        950

   2016-05-29        578

   2016-06-05        786

   2016-06-12        990

  2016-06-19       1804

  2016-06-26        853

  2016-07-03        767

  2016-07-10       1325

  2016-07-17       1872

  2016-07-24       3002

I created time series object as

`library(zoo)`

pidbookingdata <- zoo(arrangeddata$bookingqty,arrangeddata$bookingdate)

I can see in the x axis index for year 2015 and 2016

but when I use decompose function I get the below error as

decompose(pidbookingdata)
Error in decompose(pidbookingdata) :
time series has no or less than 2 periods

so, from this site I got and tried the below approach which works:

dfts <- as.ts(xts(arrangeddata$bookingqty,order.by=arrangeddata$bookingdate))

dfts

dfts <- ts(dfts, frequency=52)

dcomp <- decompose(dfts) 

the dfts data as shown below

dfts

Time Series:
Start = c(1, 1) 
End = c(3, 1) 
Frequency = 52 
  [1]  202  564  359  638  487  491  364  762  419  642  723  579 1803  437  587  803 1347  600  616
 [20] 2242 1313  264  918  420  741 2213  379  386  854 1235  726  774 1135 1127  466  987  665  997
 [39] 2800  594  715 2009 1592  499 1906 1619 1277  683 2132 1195 1250 5001  320  577  825  885 1910
 [58] 1072  615 1809 1243 1516  754  910 1766  599  536 1170 2060  719  706 1129 1807  949  653 1612
 [77] 1058 2699  617  335  527  526 1729  512 1026  824 1144  711  743  847  833 4192  576  610  645
 [96]  950  578  786  990 1804  853  767 1325 1872 3002

when I do plot(dfts)

I see the x axis index as 1.0 1.5 2 2.5 3

am I doing correct or something is wrong here? what does the indices 1.0, 1.5, 2.0 means in terms of weeks?


#2

Check out this article, it might help:

Regards,
Kunal