# Time series modeling with R on weekly data [closed]

I am trying to do time series modeling and forecasting using R based on weekly data like below -

biz week     Amount        Count
2006-12-27   973710.7     816570
2007-01-03  4503493.2    3223259
2007-01-10  2593355.9    1659136
2007-01-17  2897670.9    2127792
2007-01-24  3590427.5    2919482
2007-01-31  3761025.7    2981363
2007-02-07  3550213.1    2773988
2007-02-14  3978005.1    3219907
2007-02-21  4020536.0    3027837
2007-02-28  4038007.9    3191570
2007-03-07  3504142.2    2816720
2007-03-14  3427323.1    2703761
...
2014-02-26  99999999.9   1234567


Regarding my data, as seen above, each week is labeled by first day for the week (my weeks start on Wednesdays and end on Tuesdays). When I construct my ts object, I tried:

ts <- ts(df, frequency=52, start=c(2007,1))


The problems I have are:

1. Some years may have 53 weeks, so frequency=52 will not work for those years.
2. My starting week / date is 2006-12-27, how should I set the start parameter? Should I use: start=c(2006,52) or start=c(2007,1), since week of 2006-12-27 really crosses the year boundary?

Also, for modeling, is it better to have complete year worth of data (say for 2007 my start year if I only have partial year worth of data, is it better I should not use 2007, instead to start with 2008. What about 2014 since it is not complete year yet, shall I use what I have for model or not? Either way, I still have issue of whether or not to include those weeks in the year boundary like 2006-12-27, shall I include it as week 1 for 2007 or last week of 2006?

3. When I use ts <- ts(df, frequency=52, start=c(2007,1)) and then print it, I got results shown below, so instead of 2007.01, 2007.02, 2007.52, ..., I got 2007.000, 2007.019, ... which it gets from 1/52=0.019, which is mathematically correct but not really easy to interpret. Is there a way to label it as the date itself just like data frame or at least 2007 wk1, 2007 wk2, ...?

=========

Time Series:
Start = c(2007, 1)
End = c(2014, 11)
Frequency = 52
Amount        Count
2007.000   645575.4     493717
2007.019  2185193.2    1659577
2007.038  1016711.8     860777
2007.058  1894056.4    1450101
2007.077  2317517.6    1757219
2007.096  2522955.8    1794512
2007.115  2266107.3    1723002

4. My goal is to model this weekly data, then try to decompose it to see seasonal component, it seems like I have to use ts() function to convert to ts object then I can use decompose() function, I tried xts() function, and I got error stating "time series has no or less than 2 periods" I guess reason is because xts() won't let me specify the frequency?

xts <- xts(df,order.by=businessWeekDate)

5. I looked for the answer in this forum and other places as well, most of the examples are monthly, there are some weekly time series question, but none of the answers are straight forward.

## closed as off-topic by mkt, user158565, Michael Chernick, StatsStudent, kjetil b halvorsenJun 18 at 21:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

• "This question appears to be off-topic because EITHER it is not about statistics, machine learning, data analysis, data mining, or data visualization, OR it focuses on programming, debugging, or performing routine operations within a statistical computing platform. If the latter, you could try the support links we maintain." – user158565, Michael Chernick, StatsStudent
If this question can be reworded to fit the rules in the help center, please edit the question.

• What you could do, if you have a bit more time, is to create the time series without the frequency (with for example zoo()) and do the decomposition yourself. The method to create time series with this frequency option is complicated (what happens if you have for example a missing value) and so I always avoid it. – Kasper Mar 5 '14 at 13:14
• Thanks a lot for the input, I will definitely give it a try with zoo() or something else later, FYI , here is a link to Professor Hyndman's blog link – user3281664 Mar 6 '14 at 20:15